This is a set of files that sets up an environment that will compile an Arduino project and assemble Programmable IO (PIO) scripts into C++ header files for inclusion in Arduino source files.
I made these notes in October 2024 after spending a lot of time researching how to make PlatformIO, Arduino, and PIO work together.
(Not yet fully tested.)
- docker
- PlatformIO CLI (already installed if you use the PlatformIO IDE)
The files in this gist would be arranged on disk as follows (main.cpp
and my-pio.pio
would be your project code, and are not included here):
my-cool-project/
Dockerfile
platformio.ini
scripts/
pioasm-build-sh-wrapper.py
pioasm-build.sh
src/
main.cpp
my-pio.pio
You can either (re)build the docker image ahead of time, or let it happen as part of the PlatformIO build (see "Usage" below).
docker build -t pioasm .
If you wanted to run pioasm
against your source files manually, you could do this in the root of your project (assuming your source is in the src/
dir):
docker run --rm -v $(pwd):/code pioasm /code/src/my-pio.pio /code/src/my-pio.pio.h
Use the PlatformIO CLI to compile and upload your project to a Raspberry Pi Pico or other RP2040-based board:
pio run -e rpi -t upload
Instead of dockerizing pioasm
, you could compile and install it locally on your apt-based Linux system:
sudo apt install build-essentials cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
git clone --branch $RELEASE_TAG --depth 1 https://github.com/raspberrypi/pico-sdk.git /tmp/pico-sdk
cd /tmp/pico-sdk/tools/pioasm && \
cmake . && \
make && \
cp pioasm ~/.local/bin ### Copy to somewhere in your $PATH
Then you could either run it manually on your *.pio
files or modify pioasm-build.sh
to remove the docker bits and call the pioasm
command directly.