Microcontroller projects

RISC-V with Raspberry Pi Pico 2

last updated: 2025-09-27

Work in progress

Debug probe GP2 (blue) is CLK GP3 (green or red) is DIO

Intro

The latest political signals from China (pact with dictators Putin and Kim Jong-un) lead me to believe that it is time to boycott as far as possible Chinese microcontrollers. America is no longer the friend to Europe, with M. Trump as president. American Tech Giants get too greedy.

It is time to change. Linux as OS and RISC-V for our microcontroller. And as far as possible no more chinese or american products.

The new Raspberry Pi Pico 2 processor was designed in Europe and has beneath ARM cores 2 RISC-V (Hazard3, RV32IMAC+) cores. So let's use them.

The hard way for Assembler and C/C++

VS Code has a cool addon to use the PICO2 but we get Microsoft involved. If you need to use it look in this document: https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf

But let's try the hard way. We use a Debian based Linux distro (Kubuntu 25.04). More Infos can be found in Appendix C: Manual toolchain setup of the document above.

The SDK (Software Development Kit) provides the headers, libraries and build system needed to write assembler and C/C++ programs. As everything coming from the Raspberry Pi Foundation, the SDK is well documented: https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf.

We will use the latest SDK version 2.2 (https://github.com/raspberrypi/pico-sdk). First we create a directory called pi_pico2 in our home directory and clone the git repos to it and we download some tools needed.

mkdir ~/pi_pico2
cd ~/pi_pico2
git clone --recurse-submodules https://github.com/raspberrypi/pico-sdk.git
git clone https://github.com/raspberrypi/pico-examples.git
git clone https://github.com/raspberrypi/pico-extras.git
git clone https://github.com/raspberrypi/pico-playground.git
git clone https://github.com/raspberrypi/picotool.git
sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
sudo apt install g++ libstdc++-arm-none-eabi-newlib libusb-1.0-0-dev

To build projects we need CMake, a cross-platform tool used to build the software, and the ARM GNU Toolchain (for a first test).

Your bash session has to find the files, so we create a shell script with the necessary environment variables:

PICODIR=pi_pico2
PICO_SDK_PATH=$HOME/$PICODIR/pico-sdk
PICO_EXAMPLES_PATH=$HOME/$PICODIR/pico-examples
PICO_EXTRAS_PATH=$HOME/$PICODIR/pico-extras
PICO_PLAYGROUND_PATH=$HOME/$PICODIR/pico-playground
PICO_TINYUSB_PATH=$HOME/$PICODIR/pico-sdk/lib/tinyusb

export PICO_SDK_PATH PICO_EXAMPLES_PATH PICO_EXTRAS_PATH
export PICO_PLAYGROUND_PATH PICO_TINYUSB_PATH
export PICO_TOOLCHAIN_PATH PICO_MYLIB_PATH

Create the pico2env.sh file with nano:

cd ~/pi_pico2
nano pico2env.sh

Copy the text to the file. Save and exit (Ctrl+o, Ctrl+x).

Now we need to source the file in ~/.basrc. Add the following line to your ~/.basrc: source ~/pi_pico2/pico2env.sh

cd pico-examples mkdir build cd build cmake .. cd blink make -j4

pico-examples/blinksimple/blinksimple.c

Downloads

Interesting links