Skip to content

Instantly share code, notes, and snippets.

@thewh1teagle
Last active December 31, 2023 14:22
Show Gist options
  • Save thewh1teagle/709adce58446d7bacebc194b0ae31f69 to your computer and use it in GitHub Desktop.
Save thewh1teagle/709adce58446d7bacebc194b0ae31f69 to your computer and use it in GitHub Desktop.
Setup Raspberry PI Pico SDK in 5 minutes

Download msys2 from https://www.msys2.org/

Open MSYS2 UCRT64 terminal

Install dependencies (always use ucrt packages in ucrt terminal not mingw packages, when possible)

pacman --needed -S $MINGW_PACKAGE_PREFIX-{toolchain,cmake,libusb,arm-none-eabi-toolchain,make} git

Clone Repos

git clone https://github.com/raspberrypi/pico-sdk
git clone https://github.com/raspberrypi/picotool
git clone https://github.com/thewh1teagle/pico-samples

# Update submodules of pico sdk
cd pico-sdk
git submodule update --init

Always set before building

export PICO_SDK_PATH=$(pwd)/pico-sdk

Setup picotool

cd picotool
mkdir -p build && cd build

# Static link libraries for picotool
cmake.exe .. -G "MinGW Makefiles" -DLIBUSB_LIBRARIES=/ucrt64/lib/libusb-1.0.a -DCMAKE_EXE_LINKER_FLAGS="-static -static-libgcc -static-libstdc++"
mingw32-make.exe -j16 -static-libgcc -static-libstdc++
# Add it to /usr/bin
cp picotool.exe /usr/bin

Build sample app

cd pico-samples/app/
mkdir -p build && cd build
cmake.exe .. -DPICO_BOARD=pico_w -DPICO_PLATFORM=rp2040 -G "MinGW Makefiles"
mingw32-make.exe -j16

Upload with picotool

picotool reboot -f
picotool load -x main.uf2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment