Building RP2040 Demo Code in the Lab

V. Hunter Adams (vha3@cornell.edu)

This webpage is for students enrolled in ECE 4760/5730 at Cornell. It walks you through downloading the RP2040 C SDK and course demo code, and building that demo code.

This document assumes that the build environment has already been setup on the computer (as it is in the computer lab). For information about setting this build environment up on your own machine, please see:


Video

The video below demonstrates the entire procedure described on this webpage.


Procedure

First time

  1. Login to a lab PC using your netid and password
  2. Navigate to Start menu --> Visual Studio 2019 --> Developer PowerShell for VS 2019
  3. In the Developer powershell that opens, navigate to your own Documents directory by running:
    PS C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools> cd C:\Users\NETID\Documents
  4. Create a new directory in your documents folder called Pico by running:
    PS C:\Users\NETID\Documents> mkdir Pico
  5. Navigate into the Pico directory by running:
    PS C:\Users\NETID\Documents> cd Pico
  6. Clone the RP2040 C SDK from Raspberry Pi's github by running:
    PS C:\Users\NETID\Documents\Pico> git clone -b master https://github.com/raspberrypi/pico-sdk.git
  7. Navigate into the pico-sdk directory by running:
    PS C:\Users\NETID\Documents\Pico> cd pico-sdk
  8. Update the SDK libraries by running:
    PS C:\Users\NETID\Documents\Pico\pico-sdk> git submodule update --init
  9. Navigate back to the Pico directory by running:
    PS C:\Users\NETID\Documents\Pico\pico-sdk> cd ..
  10. Clone the course demo code by running:
    PS C:\Users\NETID\Documents\Pico> git clone -b master https://github.com/vha3/Hunter-Adams-RP2040-Demos.git
  11. Set the value of the PICO_SDK_PATH path variable by running:
    PS C:\Users\NETID\Documents\Pico> setx PICO_SDK_PATH "..\..\pico-sdk"
  12. Set the value of the PICO_TOOLCHAIN_PATH path variable by running:
    PS C:\Users\NETID\Documents\Pico> setx PICO_TOOLCHAIN_PATH "C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\"
    • If you are at PC 27 or 44 (check the sticker on the side of the PC), please raise your hand! This step is different for you.
  13. Close the Developer PowerShell for VS 2019 window. This is required for the path variable changes to take effect.
  14. Reopen a Developer PowerShell for VS 2019 window by navigating to Start menu --> Visual Studio 2019 --> Developer PowerShell for VS 2019
  15. Navigate to the demos directory by running:
    PS C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools> cd C:\Users\NETID\Documents\Pico\Hunter-Adams-RP2040-Demos\
  16. Create a new directory in the demos folder called build by running:
    PS C:\Users\NETID\Documents\Pico\Hunter-Adams-RP2040-Demos> mkdir build
  17. Navigate into the new build directory by running:
    PS C:\Users\NETID\Documents\Pico\Hunter-Adams-RP2040-Demos> cd build
  18. Prepare the build folder by running:
    PS C:\Users\NETID\Documents\Pico\Hunter-Adams-RP2040-Demos\build> cmake -G "NMake Makefiles" ..
  19. Build all demos by running:
    PS C:\Users\NETID\Documents\Pico\Hunter-Adams-RP2040-Demos\build> nmake
  20. In a Folder Explorer window, navigate into Documents/Pico/Hunter-Adams-RP2040-Demos/build. There, you will find a folder for each project in the demo repository. Each folder contains the executables for that particular project. To program the RP2040 with one of those executables, press the BOOTSEL button, plug it into the PC, and drag/drop the uf2 file for that project onto the external memory device that appears.

Every subsequent time

  1. Navigate to Start menu --> Visual Studio 2019 --> Developer PowerShell for VS 2019
  2. In the Developer powershell that opens, navigate to the build directory in the demonstrations foler by running:
    PS C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools> cd C:\Users\NETID\Documents\Pico\Hunter-Adams-RP2040-Demos\build\
  3. Build all demos by running:
    PS C:\Users\NETID\Documents\Pico\Hunter-Adams-RP2040-Demos\build> nmake
  4. In a Folder Explorer window, navigate into Documents/Pico/Hunter-Adams-RP2040-Demos/build. There, you will find a folder for each project in the demo repository. Each folder contains the executables for that particular project. To program the RP2040 with one of those executables, press the BOOTSEL button, plug it into the PC, and drag/drop the uf2 file for that project onto the external memory device that appears.