Firmware Development
GP2040-CE is written in C++ and set up as a standard Pico SDK project.
See Getting Started with the Raspberry Pi Pico.
Environment Setup
Most of this will be parroting the above linked PDF from the Raspberry Pi Foundation.
- Windows (Pico SDK)
- Windows (Manual)
- Linux
-
Download and install CMake.
-
Install NodeJS
-
Install NPM
-
Download and install pico-setup-windows-x64-standalone.
-
Download and install VSCode.
-
Download and install Windows Terminal.
-
Open Windows Terminal.
-
Download the GP2040-CE-main repository by running the following commands in the Windows Terminal. This will download the folder to
C:\Users\user\GP2040-CE
.git clone https://github.com/OpenStickCommunity/GP2040-CE.git
cd GP2040-CE
git submodule update --init
After installing the Raspberry Pi Pico SDK, you should now have a shortcut to "Pico-Visual Studio Code" (search for it using Windows Search).
- Open "Pico-Visual Studio Code" via Windows search. This is a shortcut with pre-configured environment variables (this will be explained later).
- Navigate to the Extensions window by pressing
Ctrl+Shift+X
. - Install "CMake Tools" by Microsoft.
- Open the GP2040-CE folder you downloaded earlier via "File > Open Folder."
-
Install the latestArm GNU Toolchain
-
Install latest version of CMake
-
Install Visual Studio Build tools, or the full Visual Studio Community Edition IDE
- Make sure to select the Desktop development with C++ workload
- Select the latest Windows 10 or Windows 11 SDK from the Individual Components
-
Install Python 3.10
- At the end of the installation, there is an option to disable max file path length. You want to select this.
-
Install Visual Studio Code - Optional
-
Install git
- Set default editor to anything other than VIM, such as Visual Studio Code
-
Install NodeJS and NPM
-
Clone the Pico SDK to your local computer
git clone https://github.com/raspberrypi/pico-sdk.git
cd pico-sdk
git submodule update --init
cd .. -
From a command-prompt, Clone GP2040-CE to your local computer
git clone https://github.com/OpenStickCommunity/GP2040-CE.git
cd GP2040-CE
Ubuntu
This setup assumes an understanding of Linux terminal usage.
-
Get the SDK
cd ~/
mkdir pico
cd pico
git clone https://github.com/raspberrypi/pico-sdk.git --branch master
cd pico-sdk
git submodule update --init
cd .. -
Install the toolchain
sudo apt update
sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential- May additionally need to install
libstdc++-arm-none-eabi-newlib
- May additionally need to install
-
Install NodeJS and NPM
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
sudo apt-get install -y nodejs -
Get GP2040-CE
git clone https://github.com/OpenStickCommunity/GP2040-CE.git
cd GP2040-CE
git submodule update --init
Raspberry Pi
This setup script requires approximately 2.5GB of disk space on your SD card.
-
Download the setup script
wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh
-
Make script executable and Run it.
chmod +x pico_setup.sh
-
Install NodeJS and NPM
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
sudo apt-get install -y nodejs -
Reboot your Pi
sudo reboot
-
Get GP2040-CE
git clone https://github.com/OpenStickCommunity/GP2040-CE.git
cd GP2040-CE
git submodule update --init
Building
Environment Variables
A number of new environment variables have been setup to control parts of the build flow.
Name | Default | Description |
---|---|---|
GP2040_BOARDCONFIG | Pico | The boards.h config file to use for the build. |
SKIP_WEBBUILD | FALSE | Determines whether the web configurator is built during the cmake configuration step. |
SKIP_SUBMODULES | FALSE | Determines whether the submodule init command is run automatically during the cmake configuration step. |
SDK Variables
There are a few SDK variables we take advantage of for our builds.
Name | Default | Description |
---|---|---|
PICO_BOARD | pico | This is the embedded board that the RP2040 chip is part of. By default, it assumes the Pico. This variable would match the <boardname.h> file in the board's configs folder. |
- Windows (Pico SDK)
- Windows (Manual)
- Linux
After installing the Raspberry Pi Pico SDK, you should now have a shortcut to "Pico-Visual Studio Code" (search for it using Windows Search). This shortcut should already have everything configured, allowing you to skip to step 7. If you're experiencing compilation issues, consider following the manual steps outlined here.
Ensure the PICO_SDK_PATH
environment variable is set:
- Search for "Edit environment variables for your account" in Windows.
- Under "User Variables," click "New...".
- In the dialog that appears, enter
PICO_SDK_PATH
for the Variable Name. - Click "Browse Directory" and navigate to
C:\Program Files\Raspberry Pi\Pico SDK v1.5.1\pico-sdk
for the Variable Value. - Create another new variable.
- Enter
GP2040_BOARDCONFIG
for the Variable Name. - Enter
Pico
(or the name of your edited config folder) for the Variable Value.
You can also set the variable within VSCode:
- Press
Ctrl + ,
to open the settings. - Use the search bar to find "CMake."
- Scroll until you see "CMake: Configure Environment."
- Click "Add Item."
- Key:
GP2040_BOARDCONFIG
- Value:
Pico
(or your working folder name).
When prompted, choose GCC 10.3.1 ARM NONE EABI
for "Select a kit for GP2040-CE"
From inside VSCode:
- Click the CMake icon on the left sidebar of VSCode.
- You'll see three icons at the top-right corner of the CMake project outline. Click the "Configure All Projects" icon (looks like a page with an arrow).
- Wait for the configuration process to complete. If progress isn't visible, open a new terminal in VSCode by clicking on the "Terminal" menu, then "New Terminal". A new terminal window will open at the bottom, navigate the "Output" tab.
- Click "Build All Projects" in the CMake project outline.
- The files should be in a new folder named "build" inside the GP2040-CE folder
Start in the GP2040-CE folder. From a Developer Powershell or Developer Command Command Prompt:
A new Powershell or Command Prompt session will be required after setting an environment variable.
-
Ensure you have the
PICO_SDK_PATH
environment variable set to the path to your pico-sdk folder. -
(optional) Set the
GP2040_BOARDCONFIG
environment variable to the folder name for your board configuration.- Default value is
Pico
- Default value is
-
Create a build directory, configure the build, and execute the build.
mkdir build
cd build
cmake -G "NMake Makefiles" ..
nmake -
Your UF2 file should be in the build directory.
Start in the GP2040-CE folder
-
Ensure you have the
PICO_SDK_PATH
environment variable set to the path to your pico-sdk folder. -
(optional) Set the
GP2040_BOARDCONFIG
environment variable to the folder name for your board configuration.- Default value is
Pico
- Default value is
-
Create a build directory, configure the build, and execute the build.
mkdir build
cd build
cmake ..
make -
Your UF2 file should be in the build directory.