Raspberry Pico C++ dev with Mingw

How to prepare your environment in Windows operating system and compile your blink program written in C.

Prepare compiler environment

{
  "profiles": {
   "list": [
            {
                "guid": "{17da3cac-b318-431e-8a3e-7fcdefe6d114}",
                "name": "MINGW64 / MSYS2",
                "commandline": "S:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw64",
                //"startingDirectory": "C:/msys64/home/%USERNAME%",
                "startingDirectory": "W:/work",
                "icon": "S:/msys64/mingw64.ico",
                // "fontFace": "IBM 3270",
                // "fontWeight": "normal",
                "fontSize": 12,
                "colorScheme": "GitBash"
            },
...
  • using x86_64 version, inside shell, install packages
pacman -Syuu
pacman -S pacman -S mingw-w64-x86_64-make
pacman -S mingw-w64-x86_64-arm-none-eabi-gcc
pacman -S mingw-w64-x86_64-cmake</code></pre>

Download and compile source code

git clone -b master "https://github.com/raspberrypi/pico-sdk.git"
cd pico-sdk
git submodule update --init

export PICO_SDK_PATH=/w/work/rbpico/win/pico-sdk

git clone -b master "https://github.com/raspberrypi/pico-examples.git"
cd pico-examples/
git submodule update --init

mkdir build
cd build
cmake ../ -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug
mingw32-make</code></pre>
  • First, install SDK into Widows WSL2
wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh

export SKIP_VSCODE=1
export SKIP_UART=1
export OUTDIR=/mnt/w/work/rbpico

This script will set PICO_SDK_PATH, PICO_EXAMPLES_PATH, PICO_EXTRAS_PATH, PICO_PLAYGROUND_PATH


PS: the list of msys2 package can be browsed from: https://packages.msys2.org/package/

REF: stackoverflow.com cmake-nmake-makefiles-generator-fails-to-compile