This is a minimal build template for a Raspberry Pi Pico project using the Pico SDK and CMake.
- CMake 3.13 or higher
- Pico SDK
- Update the
PICO_SDK_PATH
in theCMakeLists.txt
file with your own Pico SDK path. - Set the
PICO_BOARD
in theCMakeLists.txt
file to your specific Pico board model. - Set the
PROJECT_NAME
in theCMakeLists.txt
file with your project name.
To build the project, navigate to the project directory and run the following commands:
mkdir build
cd build
cmake ..
make
This will generate the necessary executable and other output files for your project.
After building the project, you can flash the generated binary to your Pi Pico using picotool. Here are the steps:
- Install picotool by following the instructions on the picotool GitHub page.
- Connect your Pi Pico to your computer. Hold the BOOTSEL button while connecting to enable the UF2 bootloader mode.
- Use the following command to upload the binary to your Pi Pico:
cd build
picotool load <your_project_name>.uf2
The main entry point of the project is src/main.c
. Add your source files to the add_executable
function in the CMakeLists.txt
file and link any additional Pico SDK libraries to the target_link_libraries
function.
You can enable UART output or USB output by uncommenting the respective lines in the CMakeLists.txt
file.