Building RP2040 Demo Code

V. Hunter Adams


THE EASY WAY . . .

This webpage is for students enrolled in ECE 4760/5730 at Cornell. It walks you through installing the ECE 4760 Visual Studio Code extension, and using that extension to build course demo code.

  1. Download VSCode, if you don't already have it on your machine.
  2. Download the ECE 4760 VSCode Extension. This is a fork and gentle modification of the Raspberry Pi Pico extension.
  3. Open VSCode, and click the Extensions icon.
  4. At the top-right of the Extensions window click the "..." button and select "Install from VSIX" from the drop-down menu that appears.
  5. In the file-explorer window that appears, select the .vsix file that you downloaded in step 2 above and click Install.
  6. A new extension icon will appear at the left-side of the screen that says "4760." Click it, and select "New Project From Example."
  7. Select the "Blinky" example from the dropdown menu, select "Pico" as the board type, and choose any location that you'd like for the project. For your debugger, select "DebugProbe," then click "Create."
  8. A new window will open that contains your project. Click "Compile" at the bottom of the screen to build the project. To load the project onto your Pico, hold down the Bootsel button and plug it in. Then click the "Run" icon at the bottom of the screen.

Video-demonstration of the above instructions:













THE HARD WAY . . .

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.