![An image of the Raspberry Pi board along with a pinout list](https://static.wixstatic.com/media/f51533_a42b5949c2c6409898bd3ffb38402b56~mv2.png/v1/fill/w_80,h_53,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_a42b5949c2c6409898bd3ffb38402b56~mv2.png)
The Raspberry Pi Pico is an easy development board to get started with. Flashing a binary is as simple as dragging a file onto it like a flash drive while it is in BOOTSEL mode. As a result, the board doesn't need to be connected while you are coding or building.
This how-to will show you how to set up a development environment using either Visual Studio Code or CLion on macOS. Both IDEs will require configuring CMake, which is what is used to build the code.
Install the Toolchain
Run the following commands from the terminal
brew install cmake
brew tap ArmMbed/homebrew-formulae
brew install arm-none-eabi-gcc
Clone the Repositories
Run the following commands from a folder of your choice to clone the pico-sdk repository
git clone -b master https://github.com/raspberrypi/pico-sdk.git
cd pico-sdk
git submodule update --init
Next, run the following command to get the full path of the pico-sdk
pwd
Next, copy the path and export it as PICO_SDK_PATH environment variable in your ~/.bash_profile
You will need to restart your terminal for the environment variable to work. Alternatively, you can run the following command
source ~/.bash_profile
Next, fetch the examples by running the following commands from your terminal
cd ..
git clone -b master https://github.com/raspberrypi/pico-examples.git
Configure an IDE
You will need an IDE to make development practical. Whatever IDE you choose, you will need to configure CMake.
CLion
Using CLion, open up the pico-examples folder. Be sure to confirm that you trust cmake. You will be met with an error asking you to configure PICO_SDK_PATH. Follow the steps below to accomplish that.
Click on the CLion menu name
Click on Preferences
Open up the Build, Execution, Deployment section
Click on CMake
On the right on the screen, in the Debug profile, fill out the Environment field with the appropriate value of your pico-sdk path as shown in the example below.
![A screenshot of the CMake configuration screen on CLion](https://static.wixstatic.com/media/f51533_7eed14923d3f4e1ba289ccab9ab8a762~mv2.jpg/v1/fill/w_147,h_89,al_c,q_80,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_7eed14923d3f4e1ba289ccab9ab8a762~mv2.jpg)
You will notice that I added a Release profile. You may choose to do so as well. If your settings are correct you will see an output similar to the following at the bottom of the IDE.
![A screenshot showing the successful build operation on CLion](https://static.wixstatic.com/media/f51533_e6dcfec83b08449faf9dc803bef5c627~mv2.png/v1/fill/w_49,h_10,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_e6dcfec83b08449faf9dc803bef5c627~mv2.png)
You are now ready to run a build using one of two methods:
You can build all of the artifacts by using the Build menu.
You can build one artifact by selecting it from the dropdown in the middle of the toolbar.
![A screenshot of CLion showing a build artifact selection](https://static.wixstatic.com/media/f51533_8c1910a8c16d4f6d85a5b8d04be323f6~mv2.png/v1/fill/w_49,h_27,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_8c1910a8c16d4f6d85a5b8d04be323f6~mv2.png)
I will proceed to build the blink artifact. You could take a look at the folder named blink within the pico-examples folder. It is made up of two files: a code file and a make file.
To start the build, click on the icon that looks like a hammer to the left of the dropdown. You will see some scrolling text in the build window. You should see a message with "Build Finished" when this completes.
![A screenshot of a complete build execution](https://static.wixstatic.com/media/f51533_ed417a2c8ce44535b33bf8492de7dc8f~mv2.png/v1/fill/w_49,h_11,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_ed417a2c8ce44535b33bf8492de7dc8f~mv2.png)
The resulting binary file will be in a folder called blink within a folder called cmake-build-debug (because my build used a debug profile).
![A screenshot showing the file location after the build execution](https://static.wixstatic.com/media/f51533_5001032fecc14a5da3426281e5930987~mv2.png/v1/fill/w_73,h_86,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_5001032fecc14a5da3426281e5930987~mv2.png)
At this point, you have a .uf2 file that you can flash onto your pico.
Visual Studio Code
VSCode is a pretty popular IDE. If you happen to be using it then follow these steps to set it up to work with CMake.
First, navigate to your pico-examples folder, then run the following commands
mkdir .vscode
cd .vscode
touch settings.json
Next, open up settings.json with your favorite editor and populate it with the following.
{ "cmake.environment": { "PICO_SDK_PATH":"../../pico-sdk" } }
Next, open the pico-examples folder in VSCode.
Next, install the CMake Tools extension by clicking the Extensions icon and searching for "CMake Tools". Click on the Install button for the CMake Tools extension from Microsoft.
When done, the IDE will ask whether you would like to configure the project to work with CMake.
![A pop-up asking if you would like to configure the project to work with CMake](https://static.wixstatic.com/media/f51533_6ddb72985f9d45f4a9d1d367d49cabcc~mv2.png/v1/fill/w_49,h_9,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_6ddb72985f9d45f4a9d1d367d49cabcc~mv2.png)
Click on Yes, and a menu will be presented at the top. Select the GCC compiler from Arm.
![A screen asking you to pick the compiler to use](https://static.wixstatic.com/media/f51533_3517624bd9c2410a90cee293904be7d0~mv2.png/v1/fill/w_49,h_9,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_3517624bd9c2410a90cee293904be7d0~mv2.png)
Next, click on the settings icon (wheel) under the profile icon on the left side of the screen, and choose settings.
Next, expand Extensions and click on CMake Tools.
Next, locate Cmake:Generator
Fill in the text field with "Unix Makefiles" as shown in the image below.
![](https://static.wixstatic.com/media/f51533_d33cab55408642a0a27da8029306af6d~mv2.png/v1/fill/w_49,h_28,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_d33cab55408642a0a27da8029306af6d~mv2.png)
That's all you need to do. However, it's also advisable to install the C/C++ extension from Microsoft.
The VSCode configuration will add a folder called build to your pico-examples. All of your build outputs will be contained there.
The bottom toolbar will give you buttons for choosing your build option (debug or release) as well as running the build.
The following screen shows the output of building the target called blink.
![A screenshot of the build folder after running make on VSCode](https://static.wixstatic.com/media/f51533_60f75fa16d154c6c8f5fb5e2822105d7~mv2.png/v1/fill/w_74,h_146,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_60f75fa16d154c6c8f5fb5e2822105d7~mv2.png)
You are now ready to copy the .uf2 file onto the pico board.
Flashing the Pico
My pico comes with a lovely cable with a power button on it. This makes it easier to put the board into BOOTSEL mode for accessing it as a flash storage device.
Proceed with the following steps to copy the file onto the pico board.
Open a Finder window
Navigate to any of the build folders within the pico-examples folder
Navigate to the blink folder (assuming you are using my example)
Locate the .uf2 file but don't do anything yet
Hold down the Boot button while connecting the pico to the computer (if you have a power button then this would be the time to turn it on).
Keep holding the Boot button until the pico appears as a drive in your finder window. This takes approximately 3 seconds.
Release the Boot button
copy the uf2 file across to the pico board
The above sequence will cause the board to reboot after flashing the firmware. You should now see the board blinking.
You will get an alert from your OS telling you to eject the device before disconnecting it. There isn't a way of doing that and it's fine because that is the only file you needed to copy across.
Using Arduino IDE
The Arduino IDE provides support for Raspberry Pi Pico along with other RP2040 boards such as the Arduino Nano RP2040 Connect.
If you make use of the Arduino IDE, you will not drag your file across manually. Instead, the IDE will flash the board for you. You also have the benefit of writing your code in Arduino format and making use of their libraries.
Install Board Files
Follow these steps to install the board package.
Open up the Arduino IDE
Go to Tools -> Board -> Boards Manager
Search for "RP2040"
Install the "Arduino Mbed OS RP2040 Boards" package
![A screenshot of the Arduino boards manager](https://static.wixstatic.com/media/f51533_d71270200b8648ec98f27155643f706d~mv2.png/v1/fill/w_49,h_31,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_d71270200b8648ec98f27155643f706d~mv2.png)
Select the Pico Board
Use these steps to set the board as the target in the IDE.
Go to Tools -> Board -> Arduino Mbed OS RP2040 Boards
Select Raspberry Pi Pico
![A screenshot of the board selection](https://static.wixstatic.com/media/f51533_8dd0438b01cc48f6a54f7047fbb2f597~mv2.png/v1/fill/w_49,h_31,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_8dd0438b01cc48f6a54f7047fbb2f597~mv2.png)
Open An Example Sketch
Follow these steps to open the example sketch.
Navigate to File -> Examples -> Basics
Select Blink
![An example of navigating to the blink sketch](https://static.wixstatic.com/media/f51533_70109340863a446abd58230c92a1b464~mv2.png/v1/fill/w_49,h_31,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/f51533_70109340863a446abd58230c92a1b464~mv2.png)
Flash the Sketch
Follow these steps to flash the example sketch onto the pico board.
Verify the sketch using the checkmark on the toolbar
Go to Tools -> Port and confirm that the only thing there is an incoming Bluetooth.
Disconnect the pico board if it's connected to your computer (or turn off the cable switch)
Hold down the Boot button and connect the board (or turn on the cable switch).
Go to Tools -> Port and confirm that you now have a new port. Select this.
Upload the sketch using the button on the toolbar.
The board should now reboot and you should see the onboard LED flashing.