Skip to content

Commit c2f9c8e

Browse files
authored
Merge pull request #90 from sashacmc/raspberry_pi_pico_support_blog_post
Introducing Raspberry Pi Pico Support in Zenoh Pico blog post
2 parents be07c82 + caecb8b commit c2f9c8e

File tree

2 files changed

+279
-0
lines changed

2 files changed

+279
-0
lines changed
Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
---
2+
title: "Introducing Raspberry Pi Pico Support in Zenoh-Pico"
3+
date: 2025-01-08
4+
menu: "blog"
5+
weight: 20250108
6+
description: "January 8th, 2025 -- Paris."
7+
draft: false
8+
---
9+
10+
# Introducing Raspberry Pi Pico Support in Zenoh-Pico
11+
12+
We’re excited to announce that Zenoh-Pico now supports the Raspberry Pi Pico series, including the Pico W and Pico 2 W variants! Zenoh already runs seamlessly on platforms like the Raspberry Pi Zero, providing robust communication solutions for IoT. Now, with the addition of Raspberry Pi Pico support, we’ve expanded the Zenoh ecosystem to even smaller and more constrained devices.
13+
14+
{{< figure-inline
15+
src="../../img/20250108-Introducing-Raspberry-Pi-Pico-Support-in-Zenoh-Pico/pico-family.jpg"
16+
class="figure-inline"
17+
alt="Raspberry Pi Pico Family" >}}
18+
19+
20+
## What is Zenoh-Pico?
21+
22+
Zenoh-Pico is the lightweight, native C implementation of the[ Eclipse Zenoh](http://zenoh.io) protocol, designed specifically for constrained devices. It provides a streamlined, low-resource API while maintaining compatibility with the main[ Rust Zenoh implementation](https://github.com/eclipse-zenoh/zenoh). Zenoh-Pico already supports a broad range of platforms and protocols, making it a versatile choice for embedded systems development.
23+
24+
25+
## Why Raspberry Pi Pico?
26+
27+
The [Raspberry Pi Pico family](https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html) is a cost-effective, feature-rich microcontroller platform based on the [RP2040](https://www.raspberrypi.com/documentation/microcontrollers/silicon.html#rp2040)/[RP2350](https://www.raspberrypi.com/documentation/microcontrollers/silicon.html#rp2350) chips. With its dual-core Arm Cortex-M0+ processor (or more advanced processors in the Pico 2 series), low power consumption, and extensive GPIO options, it’s a favorite among hobbyists and professionals alike. The addition of integrated Wi-Fi in the Pico W and Pico 2 W variants makes the platform even more suitable for IoT applications.
28+
29+
* **Raspberry Pi Pico and Pico W**:
30+
* **Processor**: Dual-core Arm Cortex M0+ processor at up to 133 MHz
31+
* **Flash memory**: 2 MB
32+
* **RAM**: 256 KB
33+
* **Connectivity**: GPIO, Serial (UART), USB (CDC), and Wi-Fi (Pico W only)
34+
* **Raspberry Pi Pico 2 and Pico 2 W**:
35+
* **Processor**: Dual Arm Cortex-M33 or Hazard3 processors at up to 150MHz
36+
* **Flash memory**: 4 MB
37+
* **RAM**: 520 KB
38+
* **Connectivity**: GPIO, Serial (UART), USB (CDC), and Wi-Fi (Pico 2 W only)
39+
40+
With Zenoh-Pico’s support, developers can now leverage the Raspberry Pi Pico family for reliable and efficient data communication over:
41+
42+
* **Wi-Fi:** TCP/UDP, unicast and multicast (on Pico W versions)
43+
* **Serial connections** (UART)
44+
* **USB (CDC)** — an experimental feature that offers additional connectivity options.
45+
46+
47+
## Technical Architecture
48+
49+
Zenoh-Pico for Raspberry Pi Pico uses the **Raspberry Pi Pico SDK** for hardware interfacing and communication protocols. It also integrates **FreeRTOS** to manage tasks and scheduling, providing a robust framework for real-time operations. This combination ensures efficient and reliable performance even under constrained conditions.
50+
51+
52+
## Getting Started
53+
54+
Here’s how you can set up Zenoh-Pico examples on your Raspberry Pi Pico using Ubuntu 24.04:
55+
56+
### 1. Installation Prerequisites
57+
58+
Ensure your system has the required tools and libraries:
59+
60+
```
61+
sudo apt update
62+
sudo apt install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential g++ libstdc++-arm-none-eabi-newlib
63+
```
64+
65+
### 2. Set Up the Pico SDK
66+
67+
Clone and initialize the Raspberry Pi Pico SDK:
68+
69+
```
70+
export PICO_SDK_PATH=$HOME/src/pico-sdk
71+
mkdir -p $PICO_SDK_PATH
72+
cd $PICO_SDK_PATH
73+
git clone https://github.com/raspberrypi/pico-sdk.git .
74+
git submodule update --init
75+
```
76+
77+
### 3. Prepare the FreeRTOS Kernel
78+
79+
Clone the FreeRTOS Kernel repository:
80+
81+
```
82+
export FREERTOS_KERNEL_PATH=$HOME/src/FreeRTOS-Kernel/
83+
mkdir -p $FREERTOS_KERNEL_PATH
84+
cd $FREERTOS_KERNEL_PATH
85+
git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git .
86+
git submodule update --init
87+
```
88+
89+
### 4. Build the Examples
90+
91+
Navigate to the example directory and build them:
92+
93+
```
94+
git clone //github.com/eclipse-zenoh/zenoh-pico.git .
95+
cd zenoh-pico/examples/rpi_pico
96+
cmake -Bbuild -DPICO_BOARD="pico_w" -DWIFI_SSID=wifi_network_ssid -DWIFI_PASSWORD=wifi_network_password -DZENOH_CONFIG_MODE=client -DZENOH_CONFIG_CONNECT="tcp/router_address:7447"
97+
cmake --build ./build
98+
```
99+
100+
### 5. Flash Your Raspberry Pi Pico device
101+
102+
Connect the Raspberry Pi Pico in bootloader mode and copy one of the generated `.uf2` files onto the device.
103+
104+
105+
## Connectivity Options
106+
107+
### Serial Connection
108+
109+
To connect via UART, specify pins or predefined device name and baud rate:
110+
111+
e.g.
112+
113+
```
114+
-DZENOH_CONFIG_CONNECT="serial/0.1#baudrate=38400"
115+
-DZENOH_CONFIG_CONNECT="serial/uart1_0#baudrate=38400"
116+
```
117+
118+
Valid PIN combinations and associated device names for Raspberry Pi Pico:
119+
120+
<table>
121+
<tr>
122+
<td><strong><code>PINS</code></strong>
123+
</td>
124+
<td><strong><code>Device name</code></strong>
125+
</td>
126+
</tr>
127+
<tr>
128+
<td><code>0.1</code>
129+
</td>
130+
<td><code>uart0_0</code>
131+
</td>
132+
</tr>
133+
<tr>
134+
<td><code>4.5</code>
135+
</td>
136+
<td><code>uart1_0</code>
137+
</td>
138+
</tr>
139+
<tr>
140+
<td><code>8.9</code>
141+
</td>
142+
<td><code>uart1_1</code>
143+
</td>
144+
</tr>
145+
<tr>
146+
<td><code>12.13</code>
147+
</td>
148+
<td><code>uart0_1</code>
149+
</td>
150+
</tr>
151+
<tr>
152+
<td><code>16.17</code>
153+
</td>
154+
<td><code>uart0_2</code>
155+
</td>
156+
</tr>
157+
</table>
158+
159+
160+
### USB Serial Connection (Experimental)
161+
162+
Enable this feature by compiling Zenoh-Pico with:
163+
164+
```
165+
-DZ_FEATURE_LINK_SERIAL_USB -DZ_FEATURE_UNSTABLE_API
166+
```
167+
168+
To connect via USB CDC, use:
169+
170+
```
171+
-DZENOH_CONFIG_CONNECT="serial/usb#baudrate=112500"
172+
```
173+
174+
On the host side, run:
175+
176+
```
177+
zenohd -l serial//dev/ttyACM0#baudrate=112500
178+
```
179+
180+
## Let’s Run the Zenoh Family on the Raspberry Pi Family
181+
182+
The flexibility of Zenoh allows for powerful and efficient IoT deployments across the Raspberry Pi ecosystem. Here’s an example scenario.
183+
184+
### Set Up the Zenoh Router
185+
186+
Install the Zenoh Router on a Raspberry Pi Zero:
187+
188+
```
189+
wget https://github.com/eclipse-zenoh/zenoh/releases/download/1.1.0/zenoh-1.1.0-armv7-unknown-linux-gnueabi-standalone.zip
190+
unzip zenoh-1.1.0-armv7-unknown-linux-gnueabihf-standalone.zip
191+
```
192+
193+
Start the Zenoh router:
194+
195+
```
196+
./zenohd
197+
```
198+
199+
Find the locator in the router output:
200+
201+
```
202+
2025-01-03T16:24:17.204829Z INFO main ThreadId(01) zenoh::net::runtime::orchestrator: Zenoh can be reached at: tcp/192.168.0.207:7447
203+
```
204+
205+
### Build Pico W Clients
206+
207+
Configure Zenoh-Pico Raspberry Pi Pico examples as it was shown above, but specify to use our router IP and build it:
208+
209+
```
210+
cmake -Bbuild -DPICO_BOARD="pico_w" -DWIFI_SSID=WIFI_SSID -DWIFI_PASSWORD=********* -DZENOH_CONFIG_MODE=client -DZENOH_CONFIG_CONNECT="tcp/192.168.0.207:7447"
211+
cmake --build ./build
212+
```
213+
214+
215+
### Deploy Pico W Clients
216+
217+
Hold the BOOTSEL button on Raspberry Pi Pico W and attach it to the USB port.
218+
219+
Copy compiled z_pub firmware image:
220+
221+
```
222+
cp ./build/z_pub.uf2 /media/${USER}/RPI-RP2
223+
```
224+
225+
Do the same with the z_sub and second Raspberry Pi Pico W device:
226+
227+
```
228+
cp ./build/z_sub.uf2 /media/${USER}/RPI-RP2
229+
```
230+
231+
### Check output
232+
233+
Connect to the Pico W Subscriber to check output:
234+
235+
```
236+
❯ sudo tio /dev/ttyACM0 -e -m INLCRNL,ONLCRNL -b 115200
237+
[18:12:42.639] Press ctrl-t q to quit
238+
[18:12:46.643] Connected to /dev/ttyACM0
239+
Wi-Fi connected.
240+
IP Address: 192.168.0.249
241+
Netmask: 255.255.255.0
242+
Gateway: 192.168.0.3
243+
Connect endpoint: tcp/192.168.0.207:7447
244+
Opening client session ...
245+
Declaring Subscriber on 'demo/example/**'...
246+
>> [Subscriber] Received ('demo/example/zenoh-pico-pub': '[ 0] [RPI] Pub from Zenoh-Pico!')
247+
>> [Subscriber] Received ('demo/example/zenoh-pico-pub': '[ 1] [RPI] Pub from Zenoh-Pico!')
248+
>> [Subscriber] Received ('demo/example/zenoh-pico-pub': '[ 2] [RPI] Pub from Zenoh-Pico!')
249+
>> [Subscriber] Received ('demo/example/zenoh-pico-pub': '[ 3] [RPI] Pub from Zenoh-Pico!')
250+
>> [Subscriber] Received ('demo/example/zenoh-pico-pub': '[ 4] [RPI] Pub from Zenoh-Pico!')
251+
```
252+
253+
This setup showcases the seamless integration of Zenoh-Pico on Raspberry Pi Pico devices with a Zenoh router running on Raspberry Pi Zero, creating a scalable and efficient IoT ecosystem.
254+
255+
## Memory Usage Insights
256+
257+
Running Zenoh-Pico on the Raspberry Pi Pico W provides impressive efficiency. Here’s a brief summary of memory usage:
258+
259+
260+
* **Flash Usage**: A basic configuration provided above consumes approximately 80 KB of flash memory.
261+
262+
It is around 20% for Raspberry Pi Pico or 10 % for Raspberry Pi Pico 2 !
263+
264+
* **RAM Usage**: Zenoh typically uses around 12 KB of RAM for this configuration.
265+
266+
It is around 5% for Raspberry Pi Pico or 2% for Raspberry Pi Pico 2 !
267+
268+
269+
## Future-Proofing IoT Applications
270+
271+
With support for the Raspberry Pi Pico, Zenoh-Pico continues to lead in providing robust, scalable, and efficient communication solutions for constrained devices. Whether you’re building home automation systems, industrial IoT solutions, or experimenting with new ideas, Zenoh-Pico and Raspberry Pi Pico make a powerful combination.
272+
273+
Additionally, the main Rust-based Zenoh implementation is fully compatible with the Raspberry Pi Zero, making it an excellent choice for edge routers in distributed systems.
274+
275+
We’re eager to see what the community builds with this new capability! For more details, check out the[ Zenoh-Pico repository](https://github.com/eclipse-zenoh/zenoh-pico) and join the discussion on our[ community channels](http://zenoh.io/community/).
276+
277+
Let’s build the future of IoT together!
278+
279+
**-- [Alexander Bushnev](https://github.com/sashacmc)**
188 KB
Loading

0 commit comments

Comments
 (0)