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

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



Installing Required Software

  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.

  2. Install Install CMake.

    When prompted, add CMake to the system PATH for all users.

  3. Install Visual Studio Code and .

    • 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.
  4. Install Python 3.x (I installed Python 3.9 but I believe 3.6+ works).

    • When prompted by the installer, add Python 3.x 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\Python39 and make a symlink by running C:\Program Files\Python39 > mklink python3.exe python.exe. Only do this if your build fails because Make can't find your python installation.
  5. Install Git.

    • When prompted by the installer, make sure that you change the default editor away from vim.
    • 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.
  2. Run the following set of commands:
     git clone -b master https://github.com/raspberrypi/pico-sdk.git
     cd pico-sdk
     git submodule update --init
     cd ..
     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.
  3. Set the path to the SDK by running the following:
    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.
  7. Build the "Hello World" example by running:
     cd pico-examples
     mkdir build
     cd build
     cmake -G "NMake Makefiles" ..
     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 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.