n-i-x/pico-sdk-dev-container
VSCode Dev Container for the RaspberryPi Pico SDK
RaspberryPi Pico SDK Dev Container for VSCode
This project is aimed to provide an easy-to-set-up environment to develop software for the RaspberryPi Pico with the Pico-SDK for C++ | PDF Documentation. This is a Docker image primarly used via Development containers in VSCode.
Available SDK Versions
The following Pico SDK versions are available as pre-built images:
| SDK Version | Docker Image Tag | Pico SDK Release |
|---|---|---|
| 2.2.0 | ghcr.io/n-i-x/pico-sdk-dev-container:2.2.0 |
Release 2.2.0 |
| 2.1.1 | ghcr.io/n-i-x/pico-sdk-dev-container:2.1.1 |
Release 2.1.1 |
| 2.1.0 | ghcr.io/n-i-x/pico-sdk-dev-container:2.1.0 |
Release 2.1.0 |
| 2.0.0 | ghcr.io/n-i-x/pico-sdk-dev-container:2.0.0 |
Release 2.0.0 |
| 1.5.1 | ghcr.io/n-i-x/pico-sdk-dev-container:1.5.1 |
Release 1.5.1 |
| 1.5.0 | ghcr.io/n-i-x/pico-sdk-dev-container:1.5.0 |
Release 1.5.0 |
Use latest tag for the most recent version, or pin to a specific version for reproducible builds.
What does this image provide?
Here is what you get:
- All the necessary development tools
- make
- cmake
- gcc-arm-none-eabi
- Pico SDK
- Proper configuration of the development environment
- With the provided
devcontainer.jsonyou also get:- Pre-installed extensions to work with C++, CMake
- Creature comfort extensions to make your coding experience better:
- Nice themes
- Right-click menu option to duplicate files
- Rainbow-colored indentation
- Path intellisense for better autocomplete experience
- Trailing space highlighting
- Extensions for better Markdown experience
- Spell checking
Usage
Prerequisites
If you are here for the first time, we may need to do some work before you begin coding. Make sure you have the following:
- Download and install VSCode
- Install the Dev Containers VSCode extension
- Download and install Docker
Set up your project
TODO: Simple initialization script
- Open up VSCode, and open a folder (
CTRL + k oon Windows/Linux ;CMD + oon Mac) which will be used to develop your project. - Create a
.devcontainerdirectory in the main root of the project - Create a
devcontainer.jsonfile iside of the.devcontainerfolder with the following contents:// For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu // README at: https://github.com/n-i-x/pico-sdk-dev-container { "name": "Pico-SDK Dev Container", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "ghcr.io/n-i-x/pico-sdk-dev-container:latest", "features": {}, // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. // "postCreateCommand": "", // Configure tool-specific properties. "customizations": { "vscode": { "extensions": [ "twxs.cmake", "ms-vscode.cmake-tools", "ms-vscode.cpptools", "ms-vscode.cpptools-extension-pack", "streetsidesoftware.code-spell-checker", "ms-vscode.cpptools-themes", "PKief.material-icon-theme", "mrmlnc.vscode-duplicate", "oderwat.indent-rainbow", "christian-kohler.path-intellisense", "shardulm94.trailing-spaces", "shd101wyy.markdown-preview-enhanced", "yzhang.markdown-all-in-one" ], "settings": { "editor.bracketPairColorization.enabled": true, "C_Cpp.default.includePath": [ "${workspaceFolder}/**", "${env.PICO_SDK_PATH}/**" ] } } } // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" }
- If you have C++ settings configured for your project in
.vscode/c_cpp_properties.jsonin the root directory, remove the following declaration:"includePath": [ "${workspaceFolder}/**", ],
- Run the project inside a Dev Container:
PressCTRL + SHIFT + Pto open the command palette in VSCode and select theDev Containers: Open Folder in Containeroption. - Create the
CMakeLists.txtfile with the following contents:cmake_minimum_required(VERSION 3.13) # initialize the SDK based on PICO_SDK_PATH include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) project(my_project) # initialize the Raspberry Pi Pico SDK pico_sdk_init() # rest of your project add_executable(main main.cpp ) # Add pico_stdlib library which aggregates commonly used features target_link_libraries(main pico_stdlib) # create map/bin/hex/uf2 file in addition to ELF. pico_add_extra_outputs(main)
- Now you can use the Pico SDK in your project! Create a
main.cppfile and have fun using thepiconamespace:#include <stdio.h> #include <pico/stdlib.h> int main() { setup_default_uart(); printf("Hello, world!\n"); return 0; }
- Finally, to build your project and get the
uf2firmware, run these commands:mkdir build cd build cmake .. make
You can also create a VSCode Task in .vscode/tasks.json for this usecase:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "mkdir build && cd build && cmake .. && make",
"problemMatcher": []
}
]
}Feel free to check out the example/ directory to see a sample project where everything is set up properly.