From 30602e98ea724b222b938a4aa757001bb041bb8d Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 15 May 2023 09:55:32 +0200 Subject: [PATCH 1/3] Initial: add pi pico w support --- src/AIoTC_Config.h | 5 +++++ src/tls/AIoTCUPCert.h | 2 +- src/tls/utility/TLSClientMqtt.cpp | 2 ++ src/tls/utility/TLSClientMqtt.h | 3 ++- src/tls/utility/TLSClientOta.cpp | 2 ++ src/tls/utility/TLSClientOta.h | 3 ++- src/utility/time/TimeService.cpp | 4 ++++ 7 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/AIoTC_Config.h b/src/AIoTC_Config.h index 2efb7021..6276f57c 100644 --- a/src/AIoTC_Config.h +++ b/src/AIoTC_Config.h @@ -134,6 +134,11 @@ #define HAS_TCP #endif +#if defined(ARDUINO_RASPBERRY_PI_PICO_W) + #define BOARD_HAS_SECRET_KEY + #define HAS_TCP +#endif + #if defined(BOARD_HAS_SOFTSE) || defined(BOARD_HAS_OFFLOADED_ECCX08) || defined(BOARD_HAS_ECCX08) || defined(BOARD_HAS_SE050) #define BOARD_HAS_SECURE_ELEMENT #endif diff --git a/src/tls/AIoTCUPCert.h b/src/tls/AIoTCUPCert.h index 5c933da0..40fe3c00 100644 --- a/src/tls/AIoTCUPCert.h +++ b/src/tls/AIoTCUPCert.h @@ -240,7 +240,7 @@ static const unsigned char x509_crt_bundle[] = { 0x00, 0x01 }; -#elif defined (ARDUINO_EDGE_CONTROL) +#elif defined (ARDUINO_EDGE_CONTROL) || defined (ARDUINO_RASPBERRY_PI_PICO_W) /* * https://www.amazontrust.com/repository/AmazonRootCA1.pem * https://www.amazontrust.com/repository/AmazonRootCA2.pem diff --git a/src/tls/utility/TLSClientMqtt.cpp b/src/tls/utility/TLSClientMqtt.cpp index 831f31cf..449e780f 100644 --- a/src/tls/utility/TLSClientMqtt.cpp +++ b/src/tls/utility/TLSClientMqtt.cpp @@ -59,6 +59,8 @@ void TLSClientMqtt::begin(ConnectionHandler & connection) { * https://github.com/arduino/uno-r4-wifi-usb-bridge/blob/f09ca94fdcab845b8368d4435fdac9f6999d21d2/certificates/certificates.pem#L852 */ (void)connection; +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) + setCACert(AIoTUPCert); #elif defined(ARDUINO_ARCH_ESP32) #if (ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 4)) setCACertBundle(x509_crt_bundle); diff --git a/src/tls/utility/TLSClientMqtt.h b/src/tls/utility/TLSClientMqtt.h index 837e76de..11acfb30 100644 --- a/src/tls/utility/TLSClientMqtt.h +++ b/src/tls/utility/TLSClientMqtt.h @@ -54,10 +54,11 @@ */ #include class TLSClientMqtt : public WiFiSSLClient { -#elif defined(BOARD_ESP) +#elif defined(BOARD_ESP) || defined(ARDUINO_RASPBERRY_PI_PICO_W) /* * ESP32* * ESP82* + * PICOW */ #include class TLSClientMqtt : public WiFiClientSecure { diff --git a/src/tls/utility/TLSClientOta.cpp b/src/tls/utility/TLSClientOta.cpp index f03af769..2d86c54b 100644 --- a/src/tls/utility/TLSClientOta.cpp +++ b/src/tls/utility/TLSClientOta.cpp @@ -55,6 +55,8 @@ void TLSClientOta::begin(ConnectionHandler &connection) { * https://github.com/arduino-libraries/Arduino_ESP32_OTA/blob/fc755e7d1d3946232107e2590662ee08d6ccdec4/src/tls/amazon_root_ca.h */ (void)connection; +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) + setCACert(AIoTUPCert); #elif defined(ARDUINO_ARCH_ESP32) #if (ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 4)) setCACertBundle(x509_crt_bundle); diff --git a/src/tls/utility/TLSClientOta.h b/src/tls/utility/TLSClientOta.h index 3e76433a..4ce90ae9 100644 --- a/src/tls/utility/TLSClientOta.h +++ b/src/tls/utility/TLSClientOta.h @@ -54,10 +54,11 @@ */ #include class TLSClientOta : public WiFiSSLClient { -#elif defined(BOARD_ESP) +#elif defined(BOARD_ESP) || defined(ARDUINO_RASPBERRY_PI_PICO_W) /* * ESP32* * ESP82* + * PICOW */ #include class TLSClientOta : public WiFiClientSecure { diff --git a/src/utility/time/TimeService.cpp b/src/utility/time/TimeService.cpp index 5bf081de..b0362cf8 100644 --- a/src/utility/time/TimeService.cpp +++ b/src/utility/time/TimeService.cpp @@ -341,6 +341,7 @@ void TimeServiceClass::initRTC() esp8266_initRTC(); #elif defined (ARDUINO_ARCH_RENESAS) renesas_initRTC(); +#elif defined (ARDUINO_RASPBERRY_PI_PICO_W) #else #error "RTC not available for this architecture" #endif @@ -358,6 +359,7 @@ void TimeServiceClass::setRTC(unsigned long time) esp8266_setRTC(time); #elif defined (ARDUINO_ARCH_RENESAS) renesas_setRTC(time); +#elif defined (ARDUINO_RASPBERRY_PI_PICO_W) #else #error "RTC not available for this architecture" #endif @@ -375,6 +377,8 @@ unsigned long TimeServiceClass::getRTC() return esp8266_getRTC(); #elif defined (ARDUINO_ARCH_RENESAS) return renesas_getRTC(); +#elif defined (ARDUINO_RASPBERRY_PI_PICO_W) + return 1; #else #error "RTC not available for this architecture" #endif From 56d7eded4db8d2ec4784b6f1083a0a563106c808 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 15 May 2023 10:16:52 +0200 Subject: [PATCH 2/3] pico w: Add soft RTC support --- src/utility/time/RTCMillis.cpp | 4 ++-- src/utility/time/RTCMillis.h | 4 ++-- src/utility/time/TimeService.cpp | 31 ++++++++++++++++++++++++++++--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/utility/time/RTCMillis.cpp b/src/utility/time/RTCMillis.cpp index 419236d1..91741678 100644 --- a/src/utility/time/RTCMillis.cpp +++ b/src/utility/time/RTCMillis.cpp @@ -15,7 +15,7 @@ a commercial license, send an email to license@arduino.cc. */ -#ifdef ARDUINO_ARCH_ESP8266 +#if defined (ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W) /************************************************************************************** * INCLUDE @@ -59,4 +59,4 @@ unsigned long RTCMillis::get() return _last_rtc_update_value; } -#endif /* ARDUINO_ARCH_ESP8266 */ +#endif /* ARDUINO_ARCH_ESP8266 || ARDUINO_RASPBERRY_PI_PICO_W */ diff --git a/src/utility/time/RTCMillis.h b/src/utility/time/RTCMillis.h index 1fa7e0f4..fce881fd 100644 --- a/src/utility/time/RTCMillis.h +++ b/src/utility/time/RTCMillis.h @@ -18,7 +18,7 @@ #ifndef ARDUINO_IOT_CLOUD_RTC_MILLIS_H_ #define ARDUINO_IOT_CLOUD_RTC_MILLIS_H_ -#ifdef ARDUINO_ARCH_ESP8266 +#if defined (ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W) /************************************************************************************** * INCLUDE @@ -45,6 +45,6 @@ class RTCMillis }; -#endif /* ARDUINO_ARCH_ESP8266 */ +#endif /* ARDUINO_ARCH_ESP8266 || ARDUINO_RASPBERRY_PI_PICO_W */ #endif /* ARDUINO_IOT_CLOUD_RTC_MILLIS_H_ */ diff --git a/src/utility/time/TimeService.cpp b/src/utility/time/TimeService.cpp index b0362cf8..82f3a693 100644 --- a/src/utility/time/TimeService.cpp +++ b/src/utility/time/TimeService.cpp @@ -34,7 +34,7 @@ #include #endif -#ifdef ARDUINO_ARCH_ESP8266 +#if defined (ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W) #include "RTCMillis.h" #endif @@ -50,7 +50,7 @@ RTCZero rtc; #endif -#ifdef ARDUINO_ARCH_ESP8266 +#if defined (ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W) RTCMillis rtc; #endif @@ -90,6 +90,12 @@ void renesas_setRTC(unsigned long time); unsigned long renesas_getRTC(); #endif +#ifdef ARDUINO_RASPBERRY_PI_PICO_W +void pico_w_initRTC(); +void pico_w_setRTC(unsigned long time); +unsigned long pico_w_getRTC(); +#endif + /************************************************************************************** * DEFINES **************************************************************************************/ @@ -342,6 +348,7 @@ void TimeServiceClass::initRTC() #elif defined (ARDUINO_ARCH_RENESAS) renesas_initRTC(); #elif defined (ARDUINO_RASPBERRY_PI_PICO_W) + pico_w_initRTC(); #else #error "RTC not available for this architecture" #endif @@ -360,6 +367,7 @@ void TimeServiceClass::setRTC(unsigned long time) #elif defined (ARDUINO_ARCH_RENESAS) renesas_setRTC(time); #elif defined (ARDUINO_RASPBERRY_PI_PICO_W) + pico_w_setRTC(time); #else #error "RTC not available for this architecture" #endif @@ -378,7 +386,7 @@ unsigned long TimeServiceClass::getRTC() #elif defined (ARDUINO_ARCH_RENESAS) return renesas_getRTC(); #elif defined (ARDUINO_RASPBERRY_PI_PICO_W) - return 1; + return pico_w_getRTC(); #else #error "RTC not available for this architecture" #endif @@ -513,6 +521,23 @@ unsigned long renesas_getRTC() } #endif +#ifdef ARDUINO_RASPBERRY_PI_PICO_W +void pico_w_initRTC() +{ + rtc.begin(); +} + +void pico_w_setRTC(unsigned long time) +{ + rtc.set(time); +} + +unsigned long pico_w_getRTC() +{ + return rtc.get(); +} +#endif + /****************************************************************************** * EXTERN DEFINITION ******************************************************************************/ From 4354b042ffa6ad07408ca9bacee10e11a93d1b37 Mon Sep 17 00:00:00 2001 From: pennam Date: Wed, 21 Aug 2024 17:25:36 +0200 Subject: [PATCH 3/3] ci: add Pico W to compile examples workflow --- .github/workflows/compile-examples.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 4e286b9f..0965db83 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -91,6 +91,9 @@ jobs: - fqbn: arduino:mbed_edge:edge_control type: mbed_edge artifact-name-suffix: arduino-mbed_edge-edge_control + - fqbn: "rp2040:rp2040:rpipicow" + type: rp2040 + artifact-name-suffix: rp2040-rp2040-rpipicow # make board type-specific customizations to the matrix jobs @@ -256,6 +259,13 @@ jobs: source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json sketch-paths: | - examples/ArduinoIoTCloud-DeferredOTA + # PicoW + - board: + type: rp2040 + platforms: | + # Install rp2040 platform via Boards Manager + - name: rp2040:rp2040 + source-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json steps: - name: Checkout