This repository provides a Docker-based setup for developing embedded Swift applications for the Raspberry Pi Pico and Pico W microcontrollers using Raspberry Pi Pico SDK. The instructions below guide you through building and running a Docker container and compiling Embedded Swift Examples for the Raspberry Pi Pico and Pico W.
- Docker installed on your system.
- Raspberry Pi Pico or Pico W.
Clone this repository using the following command:
git clone https://github.com/shivarajd/swift-embedded-pico-docker.git
Navigate into the cloned repository’s directory:
cd swift-embedded-pico-docker
To build the Docker image, run the following command:
docker build -t embedded-swift-rpi-pico .
To run the Docker container, execute the following command:
docker run -it --name swift-embedded-pico -v $(pwd):/mnt embedded-swift-rpi-pico
docker run -it --name swift-embedded-pico -v ${pwd}:/mnt embedded-swift-rpi-pico
docker run -it --name swift-embedded-pico -v "%cd%":/mnt embedded-swift-rpi-pico
This command mounts the current directory to /mnt
inside the Docker container, allowing you to access files on your host machine from within the container.
Follow these steps to compile the blink example for the Raspberry Pi Pico:
-
Navigate to the example directory:
cd /root/pico/swift-embedded-examples/pico-blink-sdk
-
Set the target board and generate build files with CMake:
cmake -B build -G Ninja -S . -D PICO_BOARD=pico
-
Build the project:
cmake --build build
-
Copy the generated UF2 file to the mounted directory:
cp build/swift-blinky.uf2 /mnt/swift-blinky-pico.uf2
Follow these steps to compile the blink example for the Raspberry Pi Pico W:
-
Navigate to the example directory:
cd /root/pico/swift-embedded-examples/pico-w-blink-sdk
-
Set the target board and generate build files with CMake:
cmake -B build -G Ninja -S . -D PICO_BOARD=pico_w
-
Build the project:
cmake --build build
-
Copy the generated UF2 file to the mounted directory:
cp build/swift-blinky.uf2 /mnt/swift-blinky-pico-w.uf2
You can stop and start the container without losing data.
To stop the docker container, run the following command:
docker stop swift-embedded-pico
To start the docker container, run the following command:
docker start -i swift-embedded-pico
- Connect the Pico or Pico W board via a USB cable to your computer, and make sure it's in the USB Mass Storage firmware upload mode (either hold the BOOTSEL button while plugging the board, or make sure your Flash memory doesn't contain any valid firmware).
- Copy the UF2 firmware to the Mass Storage device.
- The green LED should now be blinking in a pattern.