Skip to content

Feed Portenta H7 watchdog during OTA. #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/ArduinoIoTCloudTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,24 +583,34 @@ void ArduinoIoTCloudTCP::onOTARequest()
#endif /* OTA_STORAGE_SNU */

#if OTA_STORAGE_PORTENTA_QSPI
mbed_watchdog_reset();

Arduino_Portenta_OTA::Error ota_portenta_err = Arduino_Portenta_OTA::Error::None;
/* Use 2nd partition of QSPI (1st partition contains WiFi firmware) */
Arduino_Portenta_OTA_QSPI ota_portenta_qspi(QSPI_FLASH_FATFS_MBR, 2);

mbed_watchdog_reset();

/* Initialize the QSPI memory for OTA handling. */
if((ota_portenta_err = ota_portenta_qspi.begin()) != Arduino_Portenta_OTA::Error::None) {
DEBUG_ERROR("Arduino_Portenta_OTA_QSPI::begin() failed with %d", static_cast<int>(ota_portenta_err));
return;
}

mbed_watchdog_reset();

/* Just to be safe delete any remains from previous updates. */
remove("/fs/UPDATE.BIN");
remove("/fs/UPDATE.BIN.LZSS");

mbed_watchdog_reset();

/* Download the OTA file from the web storage location. */
int const ota_portenta_qspi_download_ret_code = ota_portenta_qspi.download((char*)(_ota_url.c_str()), true /* is_https */);
DEBUG_VERBOSE("Arduino_Portenta_OTA_QSPI::download(%s) returns %d", _ota_url.c_str(), ota_portenta_qspi_download_ret_code);

mbed_watchdog_reset();

/* Decompress the LZSS compressed OTA file. */
int const ota_portenta_qspi_decompress_ret_code = ota_portenta_qspi.decompress();
DEBUG_VERBOSE("Arduino_Portenta_OTA_QSPI::decompress() returns %d", ota_portenta_qspi_decompress_ret_code);
Expand All @@ -610,6 +620,8 @@ void ArduinoIoTCloudTCP::onOTARequest()
return;
}

mbed_watchdog_reset();

/* Schedule the firmware update. */
if((ota_portenta_err = ota_portenta_qspi.update()) != Arduino_Portenta_OTA::Error::None) {
DEBUG_ERROR("Arduino_Portenta_OTA_QSPI::update() failed with %d", static_cast<int>(ota_portenta_err));
Expand Down