RP2040 - CMake project template
A simple template for RP2040/Pico project using CMake and VSCode IDE. Contains updated docs in PDF format.
Setup
1. Fetch SDK and dependancies from GitHub
- Clone SDK from github
git clone -b rp2040 https://github.com/raspberrypi/pico-sdk.git - Fetch dependancies modules
git submodule init && git submodule update
2a. Build project using NMake toolchain (Windows)
- Construct build directory
mkdir build
cd build
- Call CMake to generate NMake project
cmake.exe -DPICO_SDK_PATH=<previous path> -G "NMake Makefiles" .. - Run build with
nmake.exeorcmake.exe -build .
2b. Build project using GNU GCC toolchain (linux-like system)
- Construct build directory
mkdir build
cd build
- Call CMake to generate project
cmake -DPICO_SDK_PATH=<previous path> -G "Unix Makefiles" .. - Run build with
makeorcmake -build .
Debugging
VSCode launch configuration are currently setup to support this debug probe:
Debug using SEGGER j-link probe
J-link tools need to be installed on the computer and accessible in PATH in order to work.
If needed, you can adapt the line "serverpath": "C:/Program Files/SEGGER/JLink_V782d/JLinkGDBServerCL.exe" in accordance with your system configuration.
Debug using RPi-Pico with Picoprobe firmware
OpenOCD should be installed or compiled on your system in order to work. One pico probe should be equipped with Picoprobe firmware (https://github.com/raspberrypi/picoprobe) and connected to the target RP2040 as the following diagram:
No more configuration is needed.
Debug using Black Magic Probe
No more tool is needed.
You can configure the GDB server port through "BMPGDBSerialPort": "\\\\.\\COM20".
Be aware of the Windows specific syntax of COM port, 1 to 9 is simply COM1-9, but from COM10 you need to preceed it with \\.\COMx.
Tools version
- Pico SDK: v2.2.0
- CMake: 3.28.3
- ARM GNU GCC: 14.2
- MSVC: v143
- VSCode: 1.74+ with Cortex-Debug (marus25.cortex-debug), PIO ASM (chris-hock.pioasm) and CMake-Tools (ms-vscode.cmake-tools)