Skip to content

Commit 0801979

Browse files
committed
Bugfix: _ota_cap is false per default, but we need to set it to true if the bootloader is in fact capable of OTA support.
1 parent b00e31f commit 0801979

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/ArduinoIoTCloudTCP.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,20 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
191191
addPropertyReal(_ota_req, "OTA_REQ", Permission::ReadWrite).onSync(DEVICE_WINS);
192192
#endif /* OTA_ENABLED */
193193

194+
#if OTA_STORAGE_PORTENTA_QSPI
195+
#define BOOTLOADER_ADDR (0x8000000)
196+
uint32_t bootloader_data_offset = 0x1F000;
197+
uint8_t* bootloader_data = (uint8_t*)(BOOTLOADER_ADDR + bootloader_data_offset);
198+
uint8_t currentBootloaderVersion = bootloader_data[1];
199+
if (currentBootloaderVersion < 22) {
200+
_ota_cap = false;
201+
DBG_WARNING(F("ArduinoIoTCloudTCP::%s In order to be ready for cloud OTA, update the bootloader"), __FUNCTION__);
202+
}
203+
else {
204+
_ota_cap = true;
205+
}
206+
#endif
207+
194208
#if OTA_STORAGE_SNU && OTA_ENABLED
195209
String const nina_fw_version = WiFi.firmwareVersion();
196210
if (nina_fw_version < "1.4.1") {
@@ -479,7 +493,8 @@ void ArduinoIoTCloudTCP::onOTARequest()
479493
/* Just to be safe delete any remains from previous updates. */
480494
remove("/fs/UPDATE.BIN.LZSS");
481495

482-
OTAPortenta.begin(QSPI_FLASH_FATFS_MBR, 2048);
496+
// Use second partition
497+
OTAPortenta.begin(QSPI_FLASH_FATFS_MBR, 2);
483498

484499
if (OTAPortenta.download(_ota_url.c_str()))
485500
{

0 commit comments

Comments
 (0)