Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 48 additions & 15 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,57 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/cpp/.devcontainer/base.Dockerfile

# [Choice] Debian / Ubuntu version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04
ARG VARIANT="ubuntu-20.04"
FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}

# [Optional] Uncomment this section to install additional packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends cmake build-essential wget ca-certificates \
gdb-multiarch automake autoconf libtool libftdi-dev libusb-1.0-0-dev pkg-config clang-format
RUN apt-get update && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get -y install --no-install-recommends \
cmake \
build-essential \
wget \
ca-certificates \
gdb-multiarch \
binutils-multiarch \
automake \
autoconf \
libtool \
libftdi-dev \
libusb-1.0-0-dev \
pkg-config \
clang-format \
python3 \
python3-tk
WORKDIR /apps
RUN wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 && \
RUN wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 && \
tar xjf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
RUN mv gcc-arm-none-eabi-10.3-2021.10 gcc-arm-none && \
ln -s /apps/gcc-arm-none/bin/arm-none-eabi-gcc /usr/bin/arm-none-eabi-gcc && \
rm gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
ENV PATH=$PATH:/apps/gcc-arm-none/bin
RUN git clone -b master https://github.com/raspberrypi/pico-sdk.git --depth=1 && cd pico-sdk && git submodule update --init
RUN cd /apps && \
git clone -b master https://github.com/raspberrypi/pico-sdk.git --depth=1 && \
cd pico-sdk && \
git submodule update --init
ENV PICO_SDK_PATH=/apps/pico-sdk
RUN git clone https://github.com/raspberrypi/openocd.git -b picoprobe --depth=1 \
&& cd openocd && ./bootstrap && ./configure --enable-ftdi --enable-sysfsgpio --enable-picoprobe && make -j 8 install \
&& cd /apps && git clone https://github.com/raspberrypi/picotool.git --depth=1 \
&& cd picotool && mkdir build && cd build && cmake ../ && make -j 8 && cp picotool /usr/local/bin \
&& cd /apps && git clone https://github.com/wtarreau/bootterm.git --depth=1 \
&& cd bootterm && make -j 8 install
RUN cd /apps && \
git clone -b master https://github.com/raspberrypi/pico-extras.git --depth=1 \
&& cd pico-extras && \
git submodule update --init
ENV PICO_EXTRAS_PATH=/apps/pico-extras
RUN cd /apps && \
git clone https://github.com/raspberrypi/pico-project-generator.git
ENV PATH=$PATH:/apps/pico-project-generator
RUN cd /apps && \
git clone https://github.com/codaris/picovga-cmake.git pico-vga
ENV PICOVGA_PATH=/apps/pico-vga
RUN cd /apps && \
git clone https://github.com/earlephilhower/arduino-pico.git arduino-pico
ENV ARDUINO_PICO_PATH=/apps/arduino-pico
RUN cd /apps && \
git clone https://github.com/earlephilhower/ArduinoCore-API.git arduino-core
ENV ARDUINO_CORE_PATH=/apps/arduino-core
RUN git clone https://github.com/raspberrypi/openocd.git -b picoprobe --depth=1 && \
cd openocd && ./bootstrap && ./configure --disable-werror --enable-ftdi --enable-sysfsgpio --enable-picoprobe && make -j 8 install && \
cd /apps && git clone https://github.com/raspberrypi/picotool.git --depth=1 && \
cd picotool && mkdir build && cd build && cmake ../ && make -j 8 && cp picotool /usr/local/bin && \
cd /apps && git clone https://github.com/wtarreau/bootterm.git --depth=1 && \
cd bootterm && make -j 8 install
RUN cd /usr/bin && ln -s /usr/bin/objdump objdump-multiarch && ln -s /usr/bin/nm nm-multiarch
73 changes: 43 additions & 30 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,51 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/mwinters-stuff/vscode-devcontainer-raspberrypi-pico
{
"name": "C++ Raspberry Pi Pico",
"build": {
"dockerfile": "Dockerfile",
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined", "--device=/dev/bus/usb", "--device=/dev/ttyACM0"],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/usr/bin/bash"
},
}
},
"name": "C++ Raspberry Pi Pico",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--privileged",
"-v", "/dev/bus/usb:/dev/bus/usb",
"--device=/dev/bus/usb",
"--device=/dev/ttyACM0"
],

// Set *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/usr/bin/bash"
}
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"marus25.cortex-debug",
"ms-vscode.cmake-tools",
"twxs.cmake",
"eamodio.gitlens",
"xaver.clang-format",
"chris-hock.pioasm"
],
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"marus25.cortex-debug",
"ms-vscode.cmake-tools",
"twxs.cmake",
"eamodio.gitlens",
"xaver.clang-format",
"chris-hock.pioasm",
"ms-vscode.cpptools-extension-pack"
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// 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": "gcc -v",
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "gcc -v",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"target/rp2040.cfg"
],
"svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
"runToMain": true,
"runToEntryPoint": "main",
// Give restart the same functionality as runToMain
"postRestartCommands": [
"break main",
Expand Down
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(CMAKE_CXX_STANDARD 17)
# set(PICO_SDK_PATH "/home/mathew/src/pico/pico-sdk")

# Pull in Raspberry Pi Pico SDK (must be before project)
include(pico_sdk_import.cmake)
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)

project(TestProject C CXX ASM)

Expand All @@ -21,24 +21,24 @@ pico_sdk_init()

# Add executable. Default name is the project name, version 0.1

add_executable(TestProject TestProject.cpp )
add_executable(${PROJECT_NAME} TestProject.cpp )

pico_set_program_name(TestProject "TestProject")
pico_set_program_version(TestProject "0.1")
#pico_set_program_name(${PROJECT_NAME} "TestProject")
#pico_set_program_version(${PROJECT_NAME} "0.1")

pico_enable_stdio_uart(TestProject 1)
pico_enable_stdio_usb(TestProject 0)
pico_enable_stdio_uart(${PROJECT_NAME} 0)
pico_enable_stdio_usb(${PROJECT_NAME} 1)

# Add the standard library to the build
target_link_libraries(TestProject pico_stdlib)
target_link_libraries(${PROJECT_NAME} pico_stdlib)

# Add any user requested libraries
target_link_libraries(TestProject
target_link_libraries(${PROJECT_NAME}
hardware_spi
hardware_i2c
hardware_dma
hardware_clocks
)

pico_add_extra_outputs(TestProject)
pico_add_extra_outputs(${PROJECT_NAME})

74 changes: 61 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,69 @@
# vscode-devcontainer-raspberrypi-pico [![Create docker image](https://github.com/mwinters-stuff/vscode-devcontainer-raspberrypi-pico/actions/workflows/build-image.yml/badge.svg)](https://github.com/mwinters-stuff/vscode-devcontainer-raspberrypi-pico/actions/workflows/build-image.yml)
VSCode Dev Container for the Raspberry PI Pico C SDK
# vscode-devcontainer-raspberrypi-pico

## Usage

Clone or download repository, copy the contents of .devcontainer into your project
Remove any existing "build" directory.

Open the folder, and allow the container to build.

# To know
* SDK is installed in /pico-sdk
* All USB devices are exported to container - so the picoprobe can be found and used.
* USB Device /dev/ttyACM0 is exported to container for monitoring
## VSCode Dev Container for the Raspberry PI Pico C SDK

## This container includes

* pico-sdk
* pico-extras
* pico-project-generator
* pico-vga
* arduino-pico
* arduino-core
* openocd - compiled for picoprobe
* arduino libraries
* picotool
* bootterm (for serial monitoring) - see https://github.com/wtarreau/bootterm

## Usage

**For an existing project**

* Clone or download the repository
* Copy the contents of .devcontainer into your project
* Copy the contents of .vscode into your project
* Remove any existing "build" directory.
* Open the folder in VSCode and allow the container to build.

**For a new project**

* Create the folder where you want to create the project.
* Copy the contents of .devcontainer into your project
* Copy the contents of .vscode into your project
* Open the folder in VSCode. When prompted reopen the folder in the container.
* Open a terminal in the dev container and execute the command "pico_project.py --gui".
* Change the project name to the name of your folder. Change the location to "/workspaces".
* Configure the rest of the project as desired but do not select Create VSCode project under the IDE options.
* Click OK to generate the code.
* Click Quit to exit the code generator.

**Build and debug the project**

* In the VSCode project Explorer pane, delete the project's build folder.
* In the VSCode left hand pane, select the Run and Debug icon
* In VSCode, press <CTRL><SHIFT>P and select the command CMake: Select a Kit
* Select the GCC 10.3.1 arm-none-eabi compiler.
* In VSCode, press <CTRL><SHIFT>P and select the command CMake: Select a Variant
* Select the Debug variant
* At the top of the screen in the Run and Debug dropdown select Cortext Debug
* Click the green arrow. If prompted to select a launch target select your project.
* The project will build and run in the debugger.

## Environment Variables

* PICO_SDK_PATH=/apps/pico-sdk
* PICO_EXTRAS_PATH=/apps/pico-extras
* PICOVGA_PATH=/apps/pico-vga
* ARDUINO_PICO_PATH=/apps/arduino-pico
* ARDUINO_CORE_PATH=/apps/arduino-core

## To know

* SDK is installed in /apps/pico-sdk
* EXTRAS is installed in /apps/pico-extras
* PICO-PROJECT-GENERATOR is installed in /apps/pico-project-generator
* PICO-VGA is installed in /apps/pico-vga
* Arduino pico libraries are available in /apps/arduino-pico
* Arduino core libraries are available in /apps/arduino-core
* All USB devices are exported to container - so the picoprobe can be found and used.
* USB Device /dev/ttyACM0 is exported to container for monitoring