Skip to content

Instantly share code, notes, and snippets.

@SlothDpal
Forked from sst311212/build_pico_fido2.sh
Last active August 17, 2026 15:59
Show Gist options
  • Select an option

  • Save SlothDpal/d8e592a3a61f1c85fb8f375a86a5c22d to your computer and use it in GitHub Desktop.

Select an option

Save SlothDpal/d8e592a3a61f1c85fb8f375a86a5c22d to your computer and use it in GitHub Desktop.
#!/bin/bash
docker build --build-arg BOARD=waveshare_rp2350_one --target firmware --output type=local,dest=./release .
sudo apt update
sudo apt full-upgrade -y
sudo apt install -y cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
cd ~/
git clone https://github.com/raspberrypi/pico-sdk --depth=1 --recursive
git clone https://github.com/raspberrypi/picotool --depth=1 --recursive
cd picotool
mkdir build
cd build
cmake .. -DPICO_SDK_PATH=~/pico-sdk
make -j $(nproc)
sudo make install
cd ~/
git clone https://github.com/sst311212/pico-fido2.git
cd ~/pico-fido2
git submodule update --init
cd ~/pico-fido2/pico-keys-sdk
git submodule update --init --recursive
mkdir ~/pico-fido2/release
mkdir ~/pico-fido2/build
cd ~/pico-fido2/build
hash=$(git rev-parse --short HEAD)
board="waveshare_rp2350_one"
rm -r ~/pico-fido2/build/*
cmake .. -DPICO_SDK_PATH=~/pico-sdk -DPICO_BOARD=$board -DVIDPID=Yubikey5 -DENABLE_EDDSA=1
make -j $(nproc)
mv pico_fido2.uf2 ../release/pico_fido2_$board-$hash.uf2
board="waveshare_rp2350_zero"
rm -r ~/pico-fido2/build/*
cmake .. -DPICO_SDK_PATH=~/pico-sdk -DPICO_BOARD=$board -DVIDPID=Yubikey5 -DENABLE_EDDSA=1
make -j $(nproc)
mv pico_fido2.uf2 ../release/pico_fido2_$board-$hash.uf2
#
# based on build_pico_fido2.sh
#
FROM ubuntu:24.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
cmake \
make \
build-essential \
python3 \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib \
pkg-config \
libusb-1.0-0-dev \
ca-certificates && \
rm -rf /var/lib/apt/lists/*
WORKDIR /opt
# ------------------------------------------------------------
# Pico SDK
# ------------------------------------------------------------
RUN git clone \
--depth=1 \
--recursive \
https://github.com/raspberrypi/pico-sdk.git
ENV PICO_SDK_PATH=/opt/pico-sdk
# ------------------------------------------------------------
# picotool
# ------------------------------------------------------------
RUN git clone \
--depth=1 \
--recursive \
https://github.com/raspberrypi/picotool.git
RUN cmake \
-S /opt/picotool \
-B /opt/picotool/build \
-DPICO_SDK_PATH=${PICO_SDK_PATH} \
-DCMAKE_BUILD_TYPE=Release && \
cmake \
--build /opt/picotool/build \
--parallel && \
cmake \
--install /opt/picotool/build
# ------------------------------------------------------------
# pico-fido2
# ------------------------------------------------------------
RUN git clone \
https://github.com/sst311212/pico-fido2.git
WORKDIR /opt/pico-fido2
# ------------------------------------------------------------
# Submodules
# ------------------------------------------------------------
RUN git submodule update --init
RUN cd pico-keys-sdk && \
git submodule update --init --recursive
# ------------------------------------------------------------
# Board configuration
#
# Can set in docker build:
#
# --build-arg BOARD=waveshare_rp2350_one
#
# or
#
# --build-arg BOARD=waveshare_rp2350_zero
#
# and etc.
# ------------------------------------------------------------
ARG BOARD=waveshare_rp2350_one
# ------------------------------------------------------------
# Build
# ------------------------------------------------------------
RUN mkdir -p /opt/pico-fido2/release && \
HASH="$(git rev-parse --short HEAD)" && \
cmake \
-S . \
-B build \
-DPICO_SDK_PATH=${PICO_SDK_PATH} \
-DPICO_BOARD=${BOARD} \
-DVIDPID=Yubikey5 \
-DENABLE_EDDSA=1 \
-DCMAKE_BUILD_TYPE=Release && \
cmake \
--build build \
--parallel && \
cp build/pico_fido2.uf2 \
"release/pico_fido2_${BOARD}-${HASH}.uf2"
# ------------------------------------------------------------
# Final stage with firmware only
# ------------------------------------------------------------
FROM scratch AS firmware
COPY --from=builder /opt/pico-fido2/release/ /
@SlothDpal

Copy link
Copy Markdown
Author
  1. mkdir pico-fido2
  2. place Dockerfile and build-firmware.sh to directory pico-fido2
  3. cd pico-fido2
  4. run: bash ./build-firmware.sh
  5. get firmware in directory release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment