Setting up the Raspberry Pi Pico for C/C++ Development on Windows¶

Documentation¶

Everything in this file comes from the Getting started with Raspberry Pi Pico for C/C++ development guide. This file contains all of the same content, just organized into an enumerated list.

Getting everything installed¶

1. Install the ARM GCC compiler.
• During installation, make sure to tick the box to register the path to the ARM compiler as an environment veraible in the Windows shell when prompted to do so. See the image below.
1. Install CMake.
• When prompted, add CMake to the system PATH for all users.
2. Install Visual Studio Code
3. Install Build Tools for Visual Studio 2019
• When prompted by the Built Tools for Visual Studio installer, you need to install the C++ build tools only.
• You must install the full "Windows 10 SDK" package as the SDK will need to build the pioasm and elf2uf2 tools locally. Removing it from the list of installed items will mean that you will be unable to build Raspberry Pi Pico binaries.
• This takes a while.
4. Install Python 3.7
• When prompted by the installer, add Python 3.7 to the system PATH for all users.
• You should be additionally disable the MAX_PATH length when prompted at the end of the installation.
• When installing, choose 'Custom installation,' click through 'Optional Features' and then under 'Advanced Features' choose 'Install for all users'
• It is possible that you will need to make a symbolic link so that the Makefile can find Python 3. To do so, type cmd in the Run Window so that the Developer Command Prompt icon appears in the Start Menu. Select the small arrow to the right of the icon, and then select "Run as administrator." Navigate to C:\Program Files\Python37 and make a symlink by running

C:\Program Files\Python37 > mklink python3.exe python.exe

Only do this if your build fails because Make can't find your python installation.
1. Install Git.
• When prompted by the installer, make sure that you change the default editor away from vim (see below)

• Tick the checkbox to allow Git to be used from third-party tools.

• Check the box "Checkout as is, commit as-is" (unless you have a strong reason not to)
• Select "Use Windows' default console window"
• Select "Enable experimental support for pseudo consoles"

Getting the SDK and examples¶

1. Open Windows PowerShell, and create a directory where you'd like to store all the Pico examples and the SDK. I put mine in C:\Users\vha3\Pico
2. Run the following set of commands:

C:\Users\vha3\Pico> git clone -b master https://github.com/raspberrypi/pico-sdk.git
C:\Users\vha3\Pico> cd pico-sdk
C:\Users\vha3\Pico\pico-sdk> git submodule update --init
C:\Users\vha3\Pico\pico-sdk> cd ..
C:\Users\vha3\Pico> git clone -b master https://github.com/raspberrypi/pico-examples.git

Building the example projects from the Command Line¶

1. From the Windows Menu, select Windows > Visual Studio 2019 > Developer Command Prompt
2. Navigate to the directory where you've installed the Pico examples and SDK. For me, it was C:\Users\vha3\Pico.
3. Set the path to the SDK by running the following:

C:\Users\vha3\Pico > setx PICO_SDK_PATH "..\..\pico-sdk"

4. Close the current command prompt window.
5. Open a new Command Prompt window by again navigating from the Windows Menu to Windows > Visual Studio 2019 > Developer Command Prompt. Closing/re-opening will set the environment variable that we configured above.
6. Navigate to the pico-examples folder. For me, this was in the directory C:\Users\vha3\Pico\pico-examples
7. Build the "Hello World" example by running:

C:\Users\vha3\Pico> cd pico-examples
C:\Users\vha3\Pico\pico-examples> mkdir build
C:\Users\vha3\Pico\pico-examples> cd build
C:\Users\vha3\Pico\pico-examples\build> cmake -G "NMake Makefiles" ..
C:\Users\vha3\Pico\pico-examples\build> nmake

8. Within the build directory, you will now find a hello_world directory. You will find directories for each of the other example projects too. These folders will contain the ELF, bin, and uf2 target files for each project. The uf2 target file can be dragged-and-dropped directly onto an RP2040 board attached to your PC via USB, as explained in the next section.

Programming the Pico¶

1. While holding down the BOOTSEL button, plug the Pico into a USB port.
2. The Pico will appear as a mass storage device in your file navigator.
3. Drag-and-drop C:\Users\vha3\Pico\pico-examples\build\blink.uf2 to the Pico, as you would if you were moving a file to a flash drive.
4. The Pico will automatically reboot, and start running the Blink example, flashing the LED.

Building the example projects from Visual Studio Code¶

1. Navigate via the Windows Menu to Windows > Visual Studio 2019 > Developer Command Prompt
2. When the command prompt window opens, type C:\Users\vha3\Pico > code. This will open Visual Studio Code with all of the correct environment variables set so that the toolchain is correctly configured.
3. Note from the guide: If you start Visual Studio Code by clicking on its desktop icon, or directly from the Start Menu, then the build environment will not be correctly configured. This can be done manually later in the CMake Tools Settings, but the easiest way to configure the Visual Studio Code environment is just to open it from a Developer Command Prompt Window where these environment variables are already set.
4. Click on the Extensions icon in the left-hend toolbar (or type Ctrl + Shift + X) and search for "CMake Tools"
5. Click the "CMake Tools" entry in the list, and then click the install button
6. Click the Cog Wheel at the bottom of the navigation bar on the left-hand side of the interface and select "Settings"
7. In the Settings pange, click on "Extensions" and the "CMake Tools configuration."
8. Scroll down to "Cmake: Configure Environment" and click on "Add Item"
9. Set the Item to PICO_SDK_PATH and set the Value to ..\..\pico-sdk as shown below
10. Scroll down to "Cmake: Generator" and enter "NMake Makefiles" into the box.
11. Close the Settings panel.
12. Navigate to File > Open Folder and navigate to the pico-examples repo, then hit "Okay."
13. You will be prompted to configure the project, as shown below. Click "Yes" and then select "GCC for arm-none-eabi" for your compiler.
14. Click the "Build" button (with a cog wheel) in the blue bottom bar of the window. This will create the build directory and run CMake and build the example projects.
15. Program the Pico by navigating to an example project directory within the build directory and drag/dropping onto the Pico, as explained in the previous section.