last updated: 2025-10-02
Work in progress
Debug probe GP2 (blue) is CLK GP3 (green or red) is DIO
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.
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.
To build projects we also need CMake, a cross-platform tool used to build the software, and the ARM GNU Toolchain (for a first test).
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
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 pico2envvars.sh file with nano:
cd ~/pi_pico2
nano pico2envvars.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/pico2envvars.sh.
Now if you open a new terminal window the environment variables are known by the system and we don't need to be root to work with the files.
Ok I'm eager to test this. Let'do blink the LED. We change the examples directory and create a directory named build in this directory and enter the directory. After this we use cmake -DPICO_BOARD=pico2 ... CMake is a powerful open-source solution for managing the software build process. It gives us control of the software compilation process using simple independent configuration files named here CMakeLists.txt. The parameter is needed because the default would be a normal pico (RP2040) instead a pico2 (RP2340). You can also use pico2_w for a pico2 with Wifi. The double dot uses the CMakeLists.txt file from the parent directory (pico-examples).
Now the build directory is populated with example directories containing a Makefile. We we change to the folder of the blink example (blink) and use make to create an executable file from the source files ('blink.c'). make needs the makefile (Makefile) created by cmake. The parameter -j4 tells to use 4 cores to do the job, If your PC has 16 cores set it to -j16 :).
cd ~/pi_pico2/pico-examples
mkdir build
cd build
cmake -DPICO_BOARD=pico2 ..
cd blink
make -j4
Cool now we have a blink.hex file and an blink.uf2 file in our blink directory. Power the pico2 while holding the BOOTSEL button. The pico2 will appear as an USB drive on your PC. Copy the blink.uf2 file to the Pico2 and the LED should blink :).
Yes the LED was blinking, but some things were not as wished.