Using Visual Studio Code with Raspberry Pi Pico:

Getting Started with Pi Pico

This month the Raspberry Pi Pico got released, and we’re mighty excited. Could this be the best means of low cost micro control available?? The Pi foundation have released their own brand of silicon and this device is known as the RP2040. There are boards in the pipeline from both Adafruit and Sparkfun, but for now, lets get started with the Pico from Raspberry Pi! 

Well call us curious, but the first thing we did is plug it into a PC running Windows 10, and up popped a USB Drive (FAT) with approx 127Mb of storage! But what now? Well the Raspberry Pi Pico is programmed using either C/C++ or MicroPython and adding a program to Pico is as easy as dragging and dropping a file while Raspberry Pi Pico is in boot mode.

Pi Pico Mass Storage
select the [Add path to environment variable] radio button

Install ARM GCC Compiler

We’re really looking forward to Arduino support being made available for the Pico. In the meantime, we recommend Visual Studio Code, and then to watch a few of the video tutorials that Microsoft put together!

You’ll also want to download a few other softwarings (we’re assuming that you don’t already have them installed, if so, please skip the ones you already have):

Firstly the Arm GCC Compiler. During the install process and before selecting [Finish], select the [Add path to environment variable] radio button.

Install CMake

Next download and install the latest version of CMake ensuring to remove any previous version. During the install be sure to select [Add CMake to the system PATH for all users] radio button.

 

CMake is an open-source system that manages the build process in an operating system and is designed to be used in conjunction with the native build environment.

 

[Add CMake to the system PATH for all users] radio button

Installing the required build tools for Visual Studio

Now download the C/C++ components and build tools for Visual Studio. You’ll find these at the bottom of the list under the heading [Tools for Visual Studio 2019]. Hit the link and your download should start immediately. Then install the file. During install select [Desktop development with C++] and [Install].

During install select [Desktop development with C++] and [Install]

Depending on the speed of your network this could take a while as the package is more than 6.5Gb! Patience is king here…. Thank goodness for coffee.

 

Once the build tools have been installed, your Windows machine will need a reboot to complete the installation.

Coffee With Proto-PIC
check the [Add Python 3.x to PATH] radio button. Then Install!

Installing Python 3

Now you’ll need to install Python 3. Just grab the latest version if you don’t already have it installed. Be sure to check the [Add Python 3.x to PATH] radio button. Then Install!

 

We’re almost there! 

Install Git and you’ll be ready for coding 🙂 Selecting the default component options is fine, and you can either use VIM as Git’s default editor, or you can change the default editor to your preferred text editor. Most people in our office use Notepad++, but I’ve got a great affinity with Textpad! Essentially go with your preference here

There is a Test function to make sure your choice is set up correctly.

Now there are a few more screen that will flash up, select the following:

  • [Let Git Decide]
  • [Git from the command line and also from 3rd-party software]
  • [Use bundled OpenSSH]
  • [Checkout as-is, commit as-is]
  • [Use Windows’ default console window]
  • [Default]
  • [Git Credential Manager Core]
  • [Enable file system caching]
  • [Enable experimental support for pseudo consoles]

Install Git!

Git Setup - Select your preferred Text Editor

And now breathe...!

Now we want to make sure that everything is working correctly. We can now use Git to download the Pico-SDK and example code created by the Raspberry Pi Foundation.

You can now either open a command prompt or open Git CMD and then navigate to a directory of your choosing, but somewhere that you want to install your repository, in my case I’ve created a folder on my Google Drive called Pico. Then type in x:\xxx> “git clone -b master https://github.com/raspberrypi/pico-sdk.git”

git clone -b master https://github.com/raspberrypi/pico-sdk.git

and hit return. The Pico SDK should now download to your chosen folder. Now navigate to the pico-sdk folder with the command “cd pico-sdk” and type the command “git submodule update –init” to update the package.

git submodule update --init

Now navigate back to your base directory with the command “cd..” and then type “git clone -b master https://github.com/raspberrypi/pico-examples.git”

git clone -b master https://github.com/raspberrypi/pico-examples.git

You can now close this command prompt.

Now we need to add the environment variable PICO_SDK_PATH: ..\..\pico-SDK. Open you System Properties, select Environment Variables, then under User Variables, select New. The name should be PICO_SDK_PATH, and the value is ..\..\pico-sdk

add the environment variable PICO_SDK_PATH: ..\..\pico-SDK

Select Ok and close these windows.

Next, open a Developer Command Prompt, but make sure to open it as an Administrator. You can do this by right clicking on the application link and selecting run as administrator.

open a Developer Command Prompt

Navigate to your Pico-examples folder, and then create a new directory names build using the “mkdir build” command. Then “cd build” to enter that new directory. The use the command “cmake -G “NMake Makefiles” ..” to build all of the Raspberry Pi Pico Example projects downloaded.

build all of the Raspberry Pi Pico Example projects downloaded

Once that command has finished and the prompt is back, type “nmake” and return. This build process will take a while.

CMake Running

You can now close down the Developer Command Prompt window. 

Next, you can open up a Windows Explorer Window and if you navigate back to your Pico Folder, open up the build folder, and you’ll see the compiled projects all laid out into individual folders.

Windows Explorer Build Folder
Scroll to Top