This section explains how to install and configure a development environment for Raspberry Pi Pico (and Pico 2) using Lubuntu 24.04.
The setup includes C/C++ compilation tools, VS Code, FreeRTOS, and USB access configuration.
Create a virtual machine with the following specifications:
- Name:
ComputerSystems_Pico - Memory: 4 GB
- Hard Disk: 25 GB
- Display: 128 MB
Once the VM is created and Lubuntu 24.04 is installed:
- Install Guest Additions (from the VirtualBox menu).
First, update the package index:
sudo apt updateThen install the essential tools for C programming and general development:
sudo apt -y install build-essential gcc gdb make git cmakeInstall dependencies needed for Pico SDK, debugging, and Python tools:
sudo apt install python3 python-is-python3 tar gdb-multiarchInstall additional libraries for OpenOCD (for debugging):
sudo apt install libusb-1.0-0-dev libhidapi-devInstall Firefox (optional but useful):
sudo apt install firefoxAllow USB serial and debugging devices access for your current user:
sudo usermod -aG dialout,plugdev $USERAdd udev rules so you can use the Pico without sudo:
-
Download and copy the following files to
/etc/udev/rules.d: -
Reload the udev rules:
sudo udevadm control --reload-rules sudo udevadm trigger
Install VS Code using Snap:
sudo snap install code --classicThen, open VS Code and install the following extensions from the Marketplace:
- C/C++ (by Microsoft)
- CMake Tools
- Raspberry Pi Pico (by Raspberry Pi)
Create a simple workspace for your C projects:
mkdir -p ~/c-playground/helloworld
cd ~/c-playground/helloworldYou can later use this folder to test your setup with simple “Hello, World” programs.
Install and configure a local copy of the FreeRTOS Kernel so that your CMake configuration can link it to your Pico project.
- Create a hidden folder for FreeRTOS and clone the kernel
mkdir ~/.freertos
cd ~/.freertos
git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git .
git checkout V11.2.0
git submodule update --init portable/ThirdParty/Community-Supported-Ports- Download the CMake import file:
Place it later in the root of your project.
- Add FreeRTOS Path to environment variable. You can either:
Option 1 – Add to .bashrc:
echo 'export FREERTOS_KERNEL_PATH="$HOME/.freertos"' >> ~/.bashrc
source ~/.bashrcOption 2 – Add to VS Code settings.json: inside your project vscode folder
"cmake.configureEnvironment": {
"FREERTOS_KERNEL_PATH": "${env:HOME}/.freertos"
},
"terminal.integrated.env.linux": {
"FREERTOS_KERNEL_PATH": "${env:HOME}/.freertos"
}- Download and save the FreeRTOSConfig.h file from:
FreeRTOSConfig_examples_common.h
It generally goes in the config folder of your project.
If you plan to generate documentation from your source code (for example, from comments written in Doxygen format), you can install Doxygen as follows:
sudo apt update
sudo apt install doxygen graphvizCheck this project CMakeLists.txt as good example. You can use this file as a reference for setting up your own project structure.
Include the Pico SDK and FreeRTOS kernel:
# Initialise the Raspberry Pi Pico SDK
pico_sdk_init()
# Include FreeRTOS Kernel libraries
include(FreeRTOS_Kernel_import.cmake)
# Include config only for FreeRTOS target.
target_include_directories(FreeRTOS-Kernel INTERFACE
${CMAKE_CURRENT_LIST_DIR}/config
)Then, define your executable and link libraries:
# Add executable
add_executable(blink
src/main.c
)
# Link libraries
target_link_libraries(blink
pico_stdlib
FreeRTOS-Kernel
FreeRTOS-Kernel-Heap4
)Once the project is created, set the following configuration in settings.json:
"raspberry-pi-pico.cmakeAutoConfigure": false,
"raspberry-pi-pico.useCmakeTools": true,
"cmake.configureOnEdit": true,
"cmake.automaticReconfigure": true,
"cmake.configureOnOpen": trueThis ensures you’re using the CMake Tools extension rather than the Pico extension for building projects.
NOTE: At some point the Ninja stop working inside the project (CMake could not find Ninja).
Hence I had to add it by hand in settings.json //ADD RIGHT PATH TO NINJA. GENERALLY NINJA IS AUTOMATICALLY DETECTED, BUT FOR SOME REASON NOT ANYMORE.
json "cmake.configureArgs": [ "-DCMAKE_MAKE_PROGRAM:FILEPATH=${userHome}/.pico-sdk/ninja/v1.12.1/ninja" ]
To verify everything is working:
- Plug in your Raspberry Pi Pico.
- In VS Code, open the Raspberry Pi Pico extension.
- Try to build and upload a simple example (like
blink). - Check the output in the serial terminal.