Skip to content

Commit b12d27e

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

27 files changed

+82
-47
lines changed

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

Lines changed: 6 additions & 3 deletions
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:
@@ -27,6 +27,7 @@ jobs:
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]
@@ -55,6 +56,8 @@ jobs:
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 4 additions & 3 deletions
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

@@ -367,7 +368,7 @@ Setup and build the examples:
367368
`ZENOH_CONFIG_LISTEN` - listen endpoint (only for peer mode, optional)
368369

369370
```bash
370-
cd examples/rpi_pico_w
371+
cd examples/rpi_pico
371372
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
372373
cmake --build ./build
373374
```

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

Lines changed: 30 additions & 6 deletions
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,24 @@ pico_sdk_init()
4659
include(../../cmake/helpers.cmake)
4760
set_default_build_type(Release)
4861

62+
if (NOT WIFI_SUPPORT_ENABLED)
63+
set(Z_FEATURE_LINK_TCP 0)
64+
set(Z_FEATURE_LINK_UDP_MULTICAST 0)
65+
set(Z_FEATURE_LINK_UDP_UNICAST 0)
66+
set(Z_FEATURE_SCOUTING_UDP 0)
67+
endif()
68+
69+
set(Z_FEATURE_LINK_SERIAL 0)
4970
set(BUILD_SHARED_LIBS OFF)
50-
set(WITH_RPI_PICO_W ON)
71+
set(WITH_RPI_PICO ON)
5172
configure_include_project(ZENOHPICO zenohpico zenohpico::lib "../.." zenohpico "https://github.com/eclipse-zenoh/zenoh-pico" "")
5273

5374
target_link_libraries(zenohpico_static
5475
hardware_uart
5576
pico_stdlib
56-
pico_cyw43_arch_lwip_sys_freertos
77+
pico_rand
5778
FreeRTOS-Kernel-Heap4
79+
${WIFI_LIB}
5880
)
5981

6082
# Configure build
@@ -71,8 +93,9 @@ target_include_directories(main PRIVATE
7193
)
7294
target_link_libraries(main
7395
pico_stdlib
74-
pico_cyw43_arch_lwip_sys_freertos
96+
pico_rand
7597
FreeRTOS-Kernel-Heap4
98+
${WIFI_LIB}
7699
)
77100

78101
function(add_example name)
@@ -81,9 +104,10 @@ function(add_example name)
81104
main
82105
hardware_uart
83106
pico_stdlib
84-
pico_cyw43_arch_lwip_sys_freertos
107+
pico_rand
85108
FreeRTOS-Kernel-Heap4
86109
zenohpico::lib
110+
${WIFI_LIB}
87111
)
88112
target_include_directories(${name} PRIVATE
89113
${CMAKE_CURRENT_LIST_DIR}

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 14 additions & 2 deletions
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

Lines changed: 0 additions & 10 deletions
This file was deleted.

extra_script.py

Lines changed: 5 additions & 5 deletions
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/system/platform/rpi_pico_w.h renamed to include/zenoh-pico/system/platform/rpi_pico.h

Lines changed: 5 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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"

src/session/scout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "zenoh-pico/link/manager.h"
1919
#include "zenoh-pico/protocol/codec/transport.h"
2020
#include "zenoh-pico/protocol/core.h"
21+
#include "zenoh-pico/system/platform.h"
2122
#include "zenoh-pico/transport/multicast.h"
2223
#include "zenoh-pico/utils/logging.h"
2324

src/system/rpi_pico_w/network.c renamed to src/system/rpi_pico/network.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
#include <stdlib.h>
1616

17-
#include "lwip/dns.h"
18-
#include "lwip/ip4_addr.h"
19-
#include "lwip/netdb.h"
20-
#include "lwip/pbuf.h"
21-
#include "lwip/sockets.h"
22-
#include "lwip/udp.h"
23-
#include "pico/cyw43_arch.h"
2417
#include "zenoh-pico/collections/string.h"
2518
#include "zenoh-pico/system/link/serial.h"
2619
#include "zenoh-pico/system/platform.h"
@@ -31,6 +24,14 @@
3124
#include "zenoh-pico/utils/result.h"
3225

3326
#if Z_FEATURE_LINK_TCP == 1
27+
#include "lwip/dns.h"
28+
#include "lwip/ip4_addr.h"
29+
#include "lwip/netdb.h"
30+
#include "lwip/pbuf.h"
31+
#include "lwip/sockets.h"
32+
#include "lwip/udp.h"
33+
#include "pico/cyw43_arch.h"
34+
3435
/*------------------ TCP sockets ------------------*/
3536
z_result_t _z_create_endpoint_tcp(_z_sys_net_endpoint_t *ep, const char *s_address, const char *s_port) {
3637
z_result_t ret = _Z_RES_OK;
File renamed without changes.

0 commit comments

Comments
 (0)