Skip to content

Commit 7576194

Browse files
committed
Add other Raspberry Pi Pico boards support
1 parent b04f08f commit 7576194

29 files changed

+95
-55
lines changed

.github/workflows/rpi_pico_w.yaml renamed to .github/workflows/rpi_pico.yaml

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Contributors:
1212
# ZettaScale Zenoh Team, <[email protected]>
1313
#
14-
name: rpi_pico_w
14+
name: rpi_pico
1515

1616
on:
1717
push:
@@ -21,12 +21,13 @@ on:
2121

2222
jobs:
2323
build:
24-
name: Build on ${{ matrix.os }}
24+
name: Build on ${{ matrix.os }} for ${{ matrix.pico_board }}
2525
runs-on: ${{ matrix.os }}
2626
strategy:
2727
fail-fast: false
2828
matrix:
2929
os: [ubuntu-latest]
30+
pico_board: ["pico", "pico_w", "pico2", "pico2_w"]
3031
steps:
3132
- uses: actions/checkout@v4
3233
- uses: jwlawson/[email protected]
@@ -48,13 +49,15 @@ jobs:
4849
export FREERTOS_KERNEL_PATH=$HOME/work/FreeRTOS-Kernel/
4950
mkdir -p $FREERTOS_KERNEL_PATH
5051
cd $FREERTOS_KERNEL_PATH
51-
git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git --branch V11.1.0 .
52+
git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git .
5253
git submodule update --init
5354
5455
- name: Build examples
5556
run: |
5657
export PICO_SDK_PATH=$HOME/work/pico-sdk
5758
export FREERTOS_KERNEL_PATH=$HOME/work/FreeRTOS-Kernel/
58-
cd $HOME/work/zenoh-pico/zenoh-pico/examples/rpi_pico_w
59-
cmake -Bbuild -DWIFI_SSID=wifi_network_ssid -DWIFI_PASSWORD=wifi_network_password
59+
cd $HOME/work/zenoh-pico/zenoh-pico/examples/rpi_pico
60+
cmake -Bbuild -DWIFI_SSID=wifi_network_ssid -DWIFI_PASSWORD=wifi_network_password -DPICO_BOARD="$PICO_BOARD"
6061
cmake --build ./build
62+
env:
63+
PICO_BOARD: ${{ matrix.pico_board}}

CMakeLists.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ include(GNUInstallDirs)
4545
option(BUILD_SHARED_LIBS "Build shared libraries if ON, otherwise build static libraries" ON)
4646
option(WITH_ZEPHYR "Build for Zephyr RTOS" OFF)
4747
option(WITH_FREERTOS_PLUS_TCP "Build for FreeRTOS RTOS and FreeRTOS-Plus-TCP network stack" OFF)
48-
option(WITH_RPI_PICO_W "Build for Raspberry Pi Pico W" OFF)
48+
option(WITH_RPI_PICO "Build for Raspberry Pi Pico" OFF)
4949
set(ZENOH_DEBUG 0 CACHE STRING "Use this to set the ZENOH_DEBUG variable")
5050
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
5151
if(CMAKE_EXPORT_COMPILE_COMMANDS)
@@ -186,7 +186,7 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Generic")
186186
pico_add_compile_definition(ZENOH_FREERTOS_PLUS_TCP)
187187
endif()
188188
elseif(CMAKE_SYSTEM_NAME MATCHES "PICO") # Raspberry Pi Pico Series
189-
pico_add_compile_definition(ZENOH_RPI_PICO_W)
189+
pico_add_compile_definition(ZENOH_RPI_PICO)
190190
set(CHECK_THREADS "OFF")
191191
else()
192192
message(FATAL_ERROR "zenoh-pico is not yet available on ${CMAKE_SYSTEM_NAME} platform")
@@ -279,7 +279,7 @@ message(STATUS "Unicast batch max size: ${BATCH_UNICAST_SIZE}")
279279
message(STATUS "Multicast batch max size: ${BATCH_MULTICAST_SIZE}")
280280
message(STATUS "Build for Zephyr RTOS: ${WITH_ZEPHYR}")
281281
message(STATUS "Build for FreeRTOS-Plus-TCP: ${WITH_FREERTOS_PLUS_TCP}")
282-
message(STATUS "Build for Raspberry Pi Pico W: ${WITH_RPI_PICO_W}")
282+
message(STATUS "Build for Raspberry Pi Pico: ${WITH_RPI_PICO}")
283283
message(STATUS "Configuring for ${CMAKE_SYSTEM_NAME}")
284284

285285
if(SKBUILD)
@@ -341,9 +341,9 @@ if(WITH_ZEPHYR)
341341
elseif(WITH_FREERTOS_PLUS_TCP)
342342
file (GLOB Sources_Freertos_Plus_TCP "src/system/freertos_plus_tcp/*.c")
343343
list(APPEND Sources ${Sources_Freertos_Plus_TCP})
344-
elseif(WITH_RPI_PICO_W)
345-
file (GLOB Sources_RPI_Pico_W "src/system/rpi_pico_w/*.c")
346-
list(APPEND Sources ${Sources_RPI_Pico_W})
344+
elseif(WITH_RPI_PICO)
345+
file (GLOB Sources_RPI_Pico "src/system/rpi_pico/*.c")
346+
list(APPEND Sources ${Sources_RPI_Pico})
347347
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "BSD" OR POSIX_COMPATIBLE)
348348
file (GLOB Sources_Unix "src/system/unix/*.c" "src/system/unix/link/*.c")
349349
list(APPEND Sources ${Sources_Unix})

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Currently, zenoh-pico provides support for the following (RT)OSs and protocols:
3434
| **OpenCR** | UDP (unicast and multicast), TCP | IPv4 | WiFi |
3535
| **Emscripten** | Websocket | IPv4, IPv6 | WiFi, Ethernet |
3636
| **FreeRTOS-Plus-TCP** | UDP (unicast), TCP | IPv4 | Ethernet |
37-
|**Raspberry Pi Pico W**| UDP (unicast and multicast), TCP | IPv4 | WiFi, Serial |
37+
| **Raspberry Pi Pico** | UDP (unicast and multicast), TCP | IPv4 | WiFi (for "W" version), Serial |
3838

3939
Check the website [zenoh.io](http://zenoh.io) and the [roadmap](https://github.com/eclipse-zenoh/roadmap) for more detailed information.
4040

@@ -330,7 +330,8 @@ To build and upload the code into the board, run the following command:
330330
platformio run -t upload
331331
```
332332

333-
#### 2.2.6. Raspberry Pi Pico W
333+
#### 2.2.6. Raspberry Pi Pico
334+
Note: tested with `Raspberry Pi Pico W` and `Raspberry Pi Pico 2 W` boards
334335

335336
Ensure your system has the necessary tools and libraries installed. Run the following commands:
336337

@@ -345,7 +346,7 @@ Set up the Raspberry Pi Pico SDK by cloning the repository:
345346
export PICO_SDK_PATH=$HOME/src/pico-sdk
346347
mkdir -p $PICO_SDK_PATH
347348
cd $PICO_SDK_PATH
348-
git clone https://github.com/raspberrypi/pico-sdk.git --branch 2.1.0 .
349+
git clone https://github.com/raspberrypi/pico-sdk.git .
349350
git submodule update --init
350351
```
351352

@@ -355,24 +356,25 @@ Clone the FreeRTOS Kernel repository for the project:
355356
export FREERTOS_KERNEL_PATH=$HOME/src/FreeRTOS-Kernel/
356357
mkdir -p $FREERTOS_KERNEL_PATH
357358
cd $FREERTOS_KERNEL_PATH
358-
git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git --branch V11.1.0 .
359+
git clone https://github.com/FreeRTOS/FreeRTOS-Kernel.git .
359360
git submodule update --init
360361
```
361362

362363
Setup and build the examples:
364+
`PICO_BOARD` - Pico board type: pico, pico_w, pico2, pico2_w (default: pico_w)
363365
`WIFI_SSID` - Wi-Fi network SSID
364366
`WIFI_PASSWORD` - Wi-Fi password
365367
`ZENOH_CONFIG_MODE` - client or peer mode (default: client)
366368
`ZENOH_CONFIG_CONNECT` - connect endpoint (only for client mode, optional)
367369
`ZENOH_CONFIG_LISTEN` - listen endpoint (only for peer mode, optional)
368370

369371
```bash
370-
cd examples/rpi_pico_w
371-
cmake -Bbuild -DWIFI_SSID=wifi_network_ssid -DWIFI_PASSWORD=wifi_network_password -DZENOH_CONFIG_MODE=[client|peer] -DZENOH_CONFIG_CONNECT=connect -DZENOH_CONFIG_LISTEN=listen
372+
cd examples/rpi_pico
373+
cmake -Bbuild -DPICO_BOARD="pico" -DWIFI_SSID=wifi_network_ssid -DWIFI_PASSWORD=wifi_network_password -DZENOH_CONFIG_MODE=[client|peer] -DZENOH_CONFIG_CONNECT=connect -DZENOH_CONFIG_LISTEN=listen
372374
cmake --build ./build
373375
```
374376

375-
To flash the Raspberry Pi Pico W board, connect it in bootloader mode (it will appear as a removable drive) and copy the generated .uf2 file onto it.
377+
To flash the Raspberry Pi Pico board, connect it in bootloader mode (it will appear as a removable drive) and copy the generated .uf2 file onto it.
376378

377379
## 3. Running the Examples
378380
The simplest way to run some of the example is to get a Docker image of the **zenoh** router (see [http://zenoh.io/docs/getting-started/quick-test/](http://zenoh.io/docs/getting-started/quick-test/)) and then to run the examples on your machine.

examples/rpi_pico_w/CMakeLists.txt renamed to examples/rpi_pico/CMakeLists.txt

+32-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
cmake_minimum_required(VERSION 3.13)
22

3+
set(PICO_BOARD "pico_w" CACHE STRING "Raspberry Pi Pico board: pico, pico_w, pico2, pico2_w")
4+
5+
set(WIFI_SUPPORT_ENABLED 0)
6+
if(PICO_BOARD STREQUAL "pico_w" OR PICO_BOARD STREQUAL "pico2_w")
7+
set(WIFI_SUPPORT_ENABLED 1)
8+
endif()
9+
310
# Set options
411
set(WIFI_SSID "" CACHE STRING "WiFi SSID")
512
set(WIFI_PASSWORD "" CACHE STRING "WiFi Password")
@@ -8,6 +15,7 @@ set(ZENOH_CONFIG_MODE "client" CACHE STRING "ZENOH_CONFIG_MODE")
815
set(ZENOH_CONFIG_CONNECT CACHE STRING "ZENOH_CONFIG_CONNECT")
916
set(ZENOH_CONFIG_LISTEN CACHE STRING "ZENOH_CONFIG_LISTEN")
1017

18+
message(STATUS "PICO_BOARD: ${PICO_BOARD}")
1119
message(STATUS "WIFI_SSID: ${WIFI_SSID}")
1220
if(WIFI_PASSWORD STREQUAL "")
1321
message(STATUS "WIFI_PASSWORD is empty")
@@ -27,7 +35,6 @@ configure_file(
2735
set(CMAKE_C_STANDARD 11)
2836

2937
# Include Raspberry Pi Pico SDK
30-
set(PICO_BOARD "pico_w")
3138
if(NOT DEFINED ENV{PICO_SDK_PATH})
3239
message(FATAL_ERROR "PICO_SDK_PATH environment variable is not set. Please set it to the location of the Pico SDK.")
3340
endif()
@@ -37,7 +44,13 @@ include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
3744
include(FreeRTOS_Kernel_import.cmake)
3845

3946
# Configure project
40-
project(zenohpico_rpi_pico_w_examples C CXX ASM)
47+
project(zenohpico_rpi_pico_examples C CXX ASM)
48+
49+
if(WIFI_SUPPORT_ENABLED)
50+
set(WIFI_LIB pico_cyw43_arch_lwip_sys_freertos)
51+
else()
52+
set(WIFI_LIB "")
53+
endif()
4154

4255
add_compile_definitions(LWIP_TIMEVAL_PRIVATE=0)
4356
pico_sdk_init()
@@ -46,15 +59,26 @@ pico_sdk_init()
4659
include(../../cmake/helpers.cmake)
4760
set_default_build_type(Release)
4861

62+
if (NOT WIFI_SUPPORT_ENABLED)
63+
declare_cache_var(Z_FEATURE_LINK_TCP 0 STRING "TCP support")
64+
declare_cache_var(Z_FEATURE_LINK_UDP_MULTICAST 0 STRING "UDP multicast support")
65+
declare_cache_var(Z_FEATURE_LINK_UDP_UNICAST 0 STRING "UDP unicast support")
66+
declare_cache_var(Z_FEATURE_SCOUTING_UDP 0 STRING "Scouting support")
67+
endif()
68+
69+
declare_cache_var(Z_FEATURE_LINK_SERIAL 1 STRING "Serial support")
70+
4971
set(BUILD_SHARED_LIBS OFF)
50-
set(WITH_RPI_PICO_W ON)
72+
set(WITH_RPI_PICO ON)
73+
5174
configure_include_project(ZENOHPICO zenohpico zenohpico::lib "../.." zenohpico "https://github.com/eclipse-zenoh/zenoh-pico" "")
5275

5376
target_link_libraries(zenohpico_static
5477
hardware_uart
5578
pico_stdlib
56-
pico_cyw43_arch_lwip_sys_freertos
79+
pico_rand
5780
FreeRTOS-Kernel-Heap4
81+
${WIFI_LIB}
5882
)
5983

6084
# Configure build
@@ -71,8 +95,9 @@ target_include_directories(main PRIVATE
7195
)
7296
target_link_libraries(main
7397
pico_stdlib
74-
pico_cyw43_arch_lwip_sys_freertos
98+
pico_rand
7599
FreeRTOS-Kernel-Heap4
100+
${WIFI_LIB}
76101
)
77102

78103
function(add_example name)
@@ -81,9 +106,10 @@ function(add_example name)
81106
main
82107
hardware_uart
83108
pico_stdlib
84-
pico_cyw43_arch_lwip_sys_freertos
109+
pico_rand
85110
FreeRTOS-Kernel-Heap4
86111
zenohpico::lib
112+
${WIFI_LIB}
87113
)
88114
target_include_directories(${name} PRIVATE
89115
${CMAKE_CURRENT_LIST_DIR}

examples/rpi_pico_w/include/config.h.in renamed to examples/rpi_pico/include/config.h.in

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef CONFIG_H
22
#define CONFIG_H
33

4+
#define WIFI_SUPPORT_ENABLED @WIFI_SUPPORT_ENABLED@
45
#define WIFI_SSID "@WIFI_SSID@"
56
#define WIFI_PASSWORD "@WIFI_PASSWORD@"
67
#define ZENOH_CONFIG_MODE "@ZENOH_CONFIG_MODE@"

examples/rpi_pico_w/main.c renamed to examples/rpi_pico/main.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212
// ZettaScale Zenoh Team, <[email protected]>
1313
//
1414

15+
#include <stdio.h>
16+
1517
#include "FreeRTOS.h"
1618
#include "config.h"
19+
20+
#if WIFI_SUPPORT_ENABLED
1721
#include "pico/cyw43_arch.h"
22+
#endif
23+
1824
#include "pico/stdlib.h"
1925
#include "task.h"
2026

@@ -23,6 +29,7 @@
2329

2430
int app_main();
2531

32+
#if WIFI_SUPPORT_ENABLED
2633
void print_ip_address() {
2734
struct netif *netif = &cyw43_state.netif[CYW43_ITF_STA];
2835
if (netif_is_up(netif)) {
@@ -33,12 +40,12 @@ void print_ip_address() {
3340
printf("Network interface is down.\n");
3441
}
3542
}
43+
#endif
3644

3745
void main_task(void *params) {
3846
(void)params;
3947

40-
vTaskDelay(pdMS_TO_TICKS(1000));
41-
48+
#if WIFI_SUPPORT_ENABLED
4249
if (cyw43_arch_init()) {
4350
printf("Failed to initialise\n");
4451
return;
@@ -58,10 +65,15 @@ void main_task(void *params) {
5865
printf("Offline mode\n");
5966
app_main();
6067
}
68+
#else
69+
app_main();
70+
#endif
6171

6272
printf("Terminate.\n");
6373

74+
#if WIFI_SUPPORT_ENABLED
6475
cyw43_arch_deinit();
76+
#endif
6577

6678
vTaskDelete(NULL);
6779
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/rpi_pico_w/include/config.h

-10
This file was deleted.

extra_script.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"-<system/emscripten/>",
2727
"-<system/espidf/>",
2828
"-<system/freertos_plus_tcp/>",
29-
"-<system/rpi_pico_w/>",
29+
"-<system/rpi_pico/>",
3030
"-<system/mbed/>",
3131
"-<system/unix/>",
3232
"-<system/flipper/>",
@@ -43,7 +43,7 @@
4343
"-<system/emscripten/>",
4444
"-<system/espidf>",
4545
"-<system/freertos_plus_tcp/>",
46-
"-<system/rpi_pico_w/>",
46+
"-<system/rpi_pico/>",
4747
"-<system/mbed/>",
4848
"-<system/unix/>",
4949
"-<system/flipper/>",
@@ -60,7 +60,7 @@
6060
"-<system/emscripten/>",
6161
"-<system/espidf>",
6262
"-<system/freertos_plus_tcp/>",
63-
"-<system/rpi_pico_w/>",
63+
"-<system/rpi_pico/>",
6464
"-<system/mbed/>",
6565
"-<system/unix/>",
6666
"-<system/flipper/>",
@@ -75,7 +75,7 @@
7575
"-<system/arduino/>",
7676
"-<system/emscripten/>",
7777
"-<system/freertos_plus_tcp/>",
78-
"-<system/rpi_pico_w/>",
78+
"-<system/rpi_pico/>",
7979
"-<system/mbed/>",
8080
"-<system/unix/>",
8181
"-<system/flipper/>",
@@ -91,7 +91,7 @@
9191
"-<system/emscripten/>",
9292
"-<system/espidf/>",
9393
"-<system/freertos_plus_tcp/>",
94-
"-<system/rpi_pico_w/>",
94+
"-<system/rpi_pico/>",
9595
"-<system/unix/>",
9696
"-<system/flipper/>",
9797
"-<system/windows/>",

include/zenoh-pico/config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define Z_FEATURE_LINK_TCP 1
3535
#define Z_FEATURE_LINK_BLUETOOTH 0
3636
#define Z_FEATURE_LINK_WS 0
37-
#define Z_FEATURE_LINK_SERIAL 1
37+
#define Z_FEATURE_LINK_SERIAL 0
3838
#define Z_FEATURE_SCOUTING_UDP 1
3939
#define Z_FEATURE_LINK_UDP_MULTICAST 1
4040
#define Z_FEATURE_LINK_UDP_UNICAST 1

include/zenoh-pico/system/platform/rpi_pico_w.h renamed to include/zenoh-pico/system/platform/rpi_pico.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
// ZettaScale Zenoh Team, <[email protected]>
1313
//
1414

15-
#ifndef ZENOH_PICO_SYSTEM_RPI_PICO_W_TYPES_H
16-
#define ZENOH_PICO_SYSTEM_RPI_PICO_W_TYPES_H
15+
#ifndef ZENOH_PICO_SYSTEM_RPI_PICO_TYPES_H
16+
#define ZENOH_PICO_SYSTEM_RPI_PICO_TYPES_H
17+
18+
#include <time.h>
1719

1820
#include "FreeRTOS.h"
1921
#include "event_groups.h"
@@ -76,4 +78,4 @@ typedef struct {
7678
}
7779
#endif
7880

79-
#endif // ZENOH_PICO_SYSTEM_RPI_PICO_W_TYPES_H
81+
#endif // ZENOH_PICO_SYSTEM_RPI_PICO_TYPES_H

include/zenoh-pico/system/platform_common.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
#include "zenoh-pico/system/platform/flipper.h"
4747
#elif defined(ZENOH_FREERTOS_PLUS_TCP)
4848
#include "zenoh-pico/system/platform/freertos_plus_tcp.h"
49-
#elif defined(ZENOH_RPI_PICO_W)
50-
#include "zenoh-pico/system/platform/rpi_pico_w.h"
49+
#elif defined(ZENOH_RPI_PICO)
50+
#include "zenoh-pico/system/platform/rpi_pico.h"
5151
#else
5252
#include "zenoh-pico/system/platform/void.h"
5353
#error "Unknown platform"

0 commit comments

Comments
 (0)