@@ -160,7 +160,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
160
160
sha256_str += buf;
161
161
});
162
162
DEBUG_VERBOSE (" SHA256: %d bytes (of %d) read" , bytes_read, app_size);
163
- #else
163
+ #elif defined(ARDUINO_ARCH_SAMD)
164
164
/* Calculate the SHA256 checksum over the firmware stored in the flash of the
165
165
* MCU. Note: As we don't know the length per-se we read chunks of the flash
166
166
* 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,
172
172
* range 0 to 0x2000, total flash size of 0x40000 bytes (256 kByte).
173
173
*/
174
174
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."
175
182
#endif
176
183
DEBUG_VERBOSE (" SHA256: HASH(%d) = %s" , strlen (sha256_str.c_str ()), sha256_str.c_str ());
177
184
_ota_img_sha256 = sha256_str;
@@ -259,6 +266,10 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
259
266
}
260
267
#endif /* OTA_STORAGE_SNU */
261
268
269
+ #if defined(ARDUINO_NANO_RP2040_CONNECT)
270
+ _ota_cap = true ;
271
+ #endif
272
+
262
273
#ifdef BOARD_HAS_OFFLOADED_ECCX08
263
274
if (String (WiFi.firmwareVersion ()) < String (" 1.4.4" )) {
264
275
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()
309
320
}
310
321
_state = next_state;
311
322
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
+
312
333
/* Check for new data from the MQTT client. */
313
334
if (_mqttClient.connected ())
314
335
_mqttClient.poll ();
@@ -491,6 +512,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
491
512
/* Request a OTA download if the hidden property
492
513
* OTA request has been set.
493
514
*/
515
+
494
516
if (_ota_req)
495
517
{
496
518
/* Clear the error flag. */
@@ -581,12 +603,16 @@ int ArduinoIoTCloudTCP::write(String const topic, byte const data[], int const l
581
603
#if OTA_ENABLED
582
604
void ArduinoIoTCloudTCP::onOTARequest ()
583
605
{
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 ());
585
607
586
608
#ifdef ARDUINO_ARCH_SAMD
587
609
_ota_error = samd_onOTARequest (_ota_url.c_str ());
588
610
#endif
589
611
612
+ #ifdef ARDUINO_NANO_RP2040_CONNECT
613
+ _ota_error = rp2040_connect_onOTARequest (_ota_url.c_str ());
614
+ #endif
615
+
590
616
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
591
617
_ota_error = portenta_h7_onOTARequest (_ota_url.c_str ());
592
618
#endif
0 commit comments