Hi all,
The Zephyr Project is "a best-in-class small, scalable, real-time operating system (RTOS) optimized for resource-constrained devices, across multiple architectures." (https://www.zephyrproject.org/learn-about/) It primarily targets microcontrollers and embedded systems.
It provides support for a large number of sensors, middlewares and boards. Among those boards are the Raspberry Pi Picos, which use the RP2040 and RP2350 microcontrollers (https://www.raspberrypi.com/documentati ... ntrollers/).
You can find further information about the Zephyr support for the Pico boards here: https://docs.zephyrproject.org/latest/b ... index.html
And the full Zephyr Getting Started guide here: https://docs.zephyrproject.org/latest/d ... index.html
This guide is intended as an express way to get the Pico micocontrollers working from a Raspberry Pi. Compared to the full installation it will significantly reduce the memory taken up by the Zephyr toolchain and get things working more quickly. I have tested it shortly before writing this post, however Zephyr is constantly being updated and so this guide may be out of date in the future.
With that said, let's get started from a blank Raspberry Pi 5 image:
Install Zephyr dependencies (there may be additional dependencies if you are using an OS other than Raspberry Pi OS, please see the Zephyr Getting Started guide):Create a directory to store everything related to Zephyr. Do not call it zephyr or things will get confusing later on!Create a Python virtual environment, activate it and install Zephyr packages:Create a manifest file and initialise the Zephyr workspace. This file contains the information which restricts the installation to Pico support. More about manifest files here: https://docs.zephyrproject.org/latest/d ... ifest.html
Update the west workspace (this stage may take several minutes as it downloads just over 1 Gb):Install Zephyr related Python packages, binary blobs and the Arm toolchain (may also take several minutes):This should complete your installation with a total memory usage of around 4.5 Gb. That is quite slim for Zephyr!
Congratulations! At this point, you should be able to build a blinky example for the Pico or Pico 2 (blinky is not yet supported for the W variants):
There are a few different ways to get this program running which we will look at.
Flash and debug with Debug Probe
The Debug Probe is designed to work with the Pico boards: https://www.raspberrypi.com/documentati ... probe.html
If you have one, wire it up now and install the Raspberry Pi fork of OpenOCD which supports the Pico boards: (Note: This has been upstreamed and should be part of the next OpenOCD release)
Then build your program again with some additional OpenOCD arguments:
If you have any issues in the next few steps, make sure the OpenOCD paths are correct and make them absolute paths if necessary.
You should now be able to flash your board:
And start the GDB debugger:
You can use this setup to debug visually, for example with the Raspberry Pi Pico Extension for VSCode. (https://marketplace.visualstudio.com/it ... ry-pi-pico) The binary can be found at build/zephyr/zephyr.elf
Program with copy and paste
If you do not have a debug, fear not! You can run the program on your Pico with just one USB cable between the Pico and your PC.
Before you plug in your Pico, hold down the BOOTSEL button. This puts the Pico into a mode where it can receive the program.
Following the instructions here (viewtopic.php?t=299680), mount the Pico and copy the UF2 file across:
Your Pico will now be running the Zephyr program!
Wifi Support
Both the Pico W and Pico 2W are supported by Zephyr and have access to the wonderful Zephyr networking stack! A great example to get started with is the Wifi shell:
Once you run this, open a serial terminal to the Pico via the Debug Probe:
Once your terminal is connected, hit enter to see the $ sign and perform a wifi scan:
Connect to your WiFi and perform a ping (put your WiFi SSID and password in place of the <> values):
Please let me know if you have any issues and have fun!
Cheers,
Tim
Magpie Embedded
The Zephyr Project is "a best-in-class small, scalable, real-time operating system (RTOS) optimized for resource-constrained devices, across multiple architectures." (https://www.zephyrproject.org/learn-about/) It primarily targets microcontrollers and embedded systems.
It provides support for a large number of sensors, middlewares and boards. Among those boards are the Raspberry Pi Picos, which use the RP2040 and RP2350 microcontrollers (https://www.raspberrypi.com/documentati ... ntrollers/).
You can find further information about the Zephyr support for the Pico boards here: https://docs.zephyrproject.org/latest/b ... index.html
And the full Zephyr Getting Started guide here: https://docs.zephyrproject.org/latest/d ... index.html
This guide is intended as an express way to get the Pico micocontrollers working from a Raspberry Pi. Compared to the full installation it will significantly reduce the memory taken up by the Zephyr toolchain and get things working more quickly. I have tested it shortly before writing this post, however Zephyr is constantly being updated and so this guide may be out of date in the future.
With that said, let's get started from a blank Raspberry Pi 5 image:
Code:
sudo apt updatesudo apt full-upgradeCode:
sudo apt install -y --no-install-recommends cmake gperf ccache dfu-util libsdl2-devCode:
mkdir zephyr_devcd zephyr_devCode:
python -m venv .venv. .venv/bin/activatepip install west pyelftoolsCode:
mkdir manifestecho "manifest: self: west-commands: scripts/west-commands.yml remotes: - name: zephyrproject-rtos url-base: https://github.com/zephyrproject-rtos projects: - name: zephyr remote: zephyrproject-rtos revision: main import: # By using name-allowlist we can clone only the modules that are # strictly needed by the application. name-allowlist: - cmsis_6 # required by the ARM port - hal_rpi_pico # required for Pico board support - hal_infineon # required for Infineon Wifi chip support" > manifest/west.ymlwest init -l manifest/Code:
west updateCode:
west packages pip --installwest blobs fetch hal_infineonwest zephyr-exportwest sdk install --install-dir . -t arm-zephyr-eabiCode:
du -h --max-depth=1 .711M ./.venv8.0K ./manifest2.3G ./zephyr-sdk-0.17.4297M ./modules8.0K ./.west1.2G ./zephyr4.5G .Code:
# Picowest build -p -b rpi_pico zephyr/samples/basic/blinky# Pico 2west build -p -b rpi_pico2/rp2350a/m33 zephyr/samples/basic/blinkyFlash and debug with Debug Probe
The Debug Probe is designed to work with the Pico boards: https://www.raspberrypi.com/documentati ... probe.html
If you have one, wire it up now and install the Raspberry Pi fork of OpenOCD which supports the Pico boards: (Note: This has been upstreamed and should be part of the next OpenOCD release)
Code:
wget https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.1.0-0/openocd-0.12.0+dev-aarch64-lin.tar.gzmkdir openocdtar xvzf openocd-0.12.0+dev-aarch64-lin.tar.gz -C openocdrm openocd-0.12.0+dev-aarch64-lin.tar.gzCode:
# Picowest build -p -b rpi_pico zephyr/samples/basic/blinky -- -DOPENOCD=openocd/openocd -DOPENOCD_DEFAULT_PATH=openocd/scripts# Pico 2west build -p -b rpi_pico2/rp2350a/m33 zephyr/samples/basic/blinky -- -DOPENOCD=openocd/openocd -DOPENOCD_DEFAULT_PATH=openocd/scriptsYou should now be able to flash your board:
Code:
west flashCode:
west debugProgram with copy and paste
If you do not have a debug, fear not! You can run the program on your Pico with just one USB cable between the Pico and your PC.
Before you plug in your Pico, hold down the BOOTSEL button. This puts the Pico into a mode where it can receive the program.
Following the instructions here (viewtopic.php?t=299680), mount the Pico and copy the UF2 file across:
Code:
sudo mkdir -p /mnt/picosudo mount /dev/sda1 /mnt/picocp build/zephyr/zephyr.uf2 /mnt/pico/sudo syncsudo umount /mnt/picoWifi Support
Both the Pico W and Pico 2W are supported by Zephyr and have access to the wonderful Zephyr networking stack! A great example to get started with is the Wifi shell:
Code:
# Pico Wwest build -p -b rpi_pico/rp2040/w zephyr/samples/net/wifi/shell/ -- -DOPENOCD=openocd/openocd -DOPENOCD_DEFAULT_PATH=openocd/scripts# Pico 2Wwest build -p -b rpi_pico2/rp2350a/m33/w zephyr/samples/net/wifi/shell/ -- -DOPENOCD=openocd/openocd -DOPENOCD_DEFAULT_PATH=openocd/scriptsCode:
# Install minicom if not installed already:sudo apt install minicom# Open a connectionminicom -D /dev/ttyACM0Code:
uart:~$ wifi scanScan requestedNum | SSID (len) | Chan (Band) | RSSI | Security | BS1 | TP-Link_AF55 12 | 3 (2.4GHz) | -60 | WPA2-PSK | DC2 | TP-Link_AF55 12 | 3 (2.4GHz) | -61 | WPA2-PSK | DC3 | TP-Link_AF55 12 | 3 (2.4GHz) | -62 | WPA2-PSK | DCCode:
uart:~$ wifi connect -s "<My SSID>" -p "<my password>"Passphrase provided without security configurationConnectedConnection requested[00:01:58.536,000] <inf> net_dhcpv4: Received: 192.168.1.166uart:~$ net ping 8.8.8.8PING 8.8.8.828 bytes from 8.8.8.8 to 192.168.1.166: icmp_seq=1 ttl=115 time=22 ms28 bytes from 8.8.8.8 to 192.168.1.166: icmp_seq=3 ttl=115 time=50 msuart:~$Cheers,
Tim
Magpie Embedded
Statistics: Posted by MagpieEmbedded — Tue Sep 09, 2025 10:57 pm