@@ -160,7 +160,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
160160 sha256_str += buf;
161161 });
162162 DEBUG_VERBOSE (" SHA256: %d bytes (of %d) read" , bytes_read, app_size);
163- #else
163+ #elif defined(ARDUINO_ARCH_SAMD)
164164 /* Calculate the SHA256 checksum over the firmware stored in the flash of the
165165 * MCU. Note: As we don't know the length per-se we read chunks of the flash
166166 * until we detect one containing only 0xFF (= flash erased). This only works
@@ -172,6 +172,13 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
172172 * range 0 to 0x2000, total flash size of 0x40000 bytes (256 kByte).
173173 */
174174 String const sha256_str = FlashSHA256::calc (0x2000 , 0x40000 - 0x2000 );
175+ #elif defined(ARDUINO_NANO_RP2040_CONNECT)
176+ /* The maximum size of a RP2040 OTA update image is 1 MByte (that is 1024 *
177+ * 1024 bytes or 0x100'000 bytes).
178+ */
179+ String const sha256_str = FlashSHA256::calc (XIP_BASE, 0x100000 );
180+ #else
181+ # error "No method for SHA256 checksum calculation over application image defined for this architecture."
175182#endif
176183 DEBUG_VERBOSE (" SHA256: HASH(%d) = %s" , strlen (sha256_str.c_str ()), sha256_str.c_str ());
177184 _ota_img_sha256 = sha256_str;
@@ -259,6 +266,10 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
259266 }
260267#endif /* OTA_STORAGE_SNU */
261268
269+ #if defined(ARDUINO_NANO_RP2040_CONNECT)
270+ _ota_cap = true ;
271+ #endif
272+
262273#ifdef BOARD_HAS_OFFLOADED_ECCX08
263274 if (String (WiFi.firmwareVersion ()) < String (" 1.4.4" )) {
264275 DEBUG_ERROR (" ArduinoIoTCloudTCP::%s In order to connect to Arduino IoT Cloud, NINA firmware needs to be >= 1.4.4, current %s" , __FUNCTION__, WiFi.firmwareVersion ());
@@ -309,6 +320,16 @@ void ArduinoIoTCloudTCP::update()
309320 }
310321 _state = next_state;
311322
323+ /* This watchdog feed is actually needed only by the RP2040 CONNECT cause its
324+ * maximum watchdog window is 8388ms; despite this we feed it for all
325+ * supported ARCH to keep code aligned.
326+ */
327+ #ifdef ARDUINO_ARCH_SAMD
328+ samd_watchdog_reset ();
329+ #elif defined(ARDUINO_ARCH_MBED)
330+ mbed_watchdog_reset ();
331+ #endif
332+
312333 /* Check for new data from the MQTT client. */
313334 if (_mqttClient.connected ())
314335 _mqttClient.poll ();
@@ -491,6 +512,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
491512 /* Request a OTA download if the hidden property
492513 * OTA request has been set.
493514 */
515+
494516 if (_ota_req)
495517 {
496518 /* Clear the error flag. */
@@ -581,12 +603,16 @@ int ArduinoIoTCloudTCP::write(String const topic, byte const data[], int const l
581603#if OTA_ENABLED
582604void ArduinoIoTCloudTCP::onOTARequest ()
583605{
584- DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s _ota_url = %s" , __FUNCTION__, _ota_url.c_str ());
606+ DEBUG_INFO (" ArduinoIoTCloudTCP::%s _ota_url = %s" , __FUNCTION__, _ota_url.c_str ());
585607
586608#ifdef ARDUINO_ARCH_SAMD
587609 _ota_error = samd_onOTARequest (_ota_url.c_str ());
588610#endif
589611
612+ #ifdef ARDUINO_NANO_RP2040_CONNECT
613+ _ota_error = rp2040_connect_onOTARequest (_ota_url.c_str ());
614+ #endif
615+
590616#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
591617 _ota_error = portenta_h7_onOTARequest (_ota_url.c_str ());
592618#endif
0 commit comments