Welcome to PicoDevEnv, a simplified Raspberry Pi Pico C++ SDK setup using Docker DevContainers. This repository provides a complete development environment for Raspberry Pi Pico that operates within a Docker container.
Using Docker DevContainers for your development environment has several benefits:
-
Consistency: Docker containers ensure that the environment remains the same across different machines. This eliminates the "it works on my machine" problem.
-
Portability: With Docker, you can easily share your development environment. Anyone can clone your repository and get the exact same environment.
-
Isolation: Docker isolates your development environment from your local system, protecting your local machine from potential conflicts with system libraries or resources.
-
Versatility: Docker makes it easy to set up complex environments, which can be particularly useful when working with hardware-focused programming like the Raspberry Pi Pico.
Make sure you have Visual Studio Code, Docker, and the Remote - Containers extension installed on your machine.
Follow these steps to get your environment set up:
-
Clone this repository to your local machine.
-
Open the cloned repository with Visual Studio Code.
-
At the bottom-left corner of the VSCode window, you will find the "Remote Window" button (it looks like "><" ). Click it and choose the "Reopen in Container" option. VSCode will then start building the Docker container which may take some time during the first run.
-
Once the container is built and the folder is reopened in the container, the development environment is ready to use.
To build your project:
-
Open a terminal in VSCode (which will be within the Docker environment).
-
Navigate to the
build
directory in your project. -
Run the
make
command. This will compile your code and produce a.uf2
file. -
Once the build process is complete, you can find the
.uf2
file in thebuild
directory. This file can be copied to a Raspberry Pi Pico in boot select mode to run the program.
Happy coding with your Raspberry Pi Pico!
This development environment is set up to use the pico_w
board by default. The board configuration is specified in the devcontainer.json
file with the postCreateCommand
:
"postCreateCommand": "mkdir -p build && cd build && cmake .. -DPICO_BOARD=pico_w"
If you're using a different board, you can easily update this configuration:
-
Open the
devcontainer.json
file in the root directory of your project. -
Look for the
postCreateCommand
property. -
Replace
pico_w
in thecmake
command with the name of your board. For example, if you're using the Raspberry Pi Pico, change thecmake
command to:
"postCreateCommand": "mkdir -p build && cd build && cmake .. -DPICO_BOARD=pico"
-
Save the
devcontainer.json
file. -
Rebuild your Docker container. In VS Code, you can use the "Remote Containers: Rebuild Container" command.
After the container is rebuilt, the new board configuration will be used when building your project.
Remember, the board name must match one of the boards defined in the SDK. You can find the list of boards in the pico/boards/include/boards
directory in the SDK.
-
Rebuild the Docker Image: After updating the SDK, you'll need to rebuild your Docker image to include the latest changes. Go back to the root directory of your project and rebuild the Docker image. In VS Code, you can use the "Remote Containers: Rebuild Container" command.
-
Recompile Your Project: After updating the SDK, you should recompile your project to ensure it works with the updated SDK. Navigate to your build directory and run make.
cd /workspace/build
make