Skip to content

Commit 06267fb

Browse files
committed
Unmount before performing a reset.
1 parent fc5dd4f commit 06267fb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/utility/ota/OTA-nano-rp2040.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
9191
if ((err = flash.init()) < 0)
9292
{
9393
DEBUG_ERROR("%s: flash.init() failed with %d", __FUNCTION__, err);
94-
return err;
94+
return static_cast<int>(OTAError::RP2040_ErrorFlashInit);
9595
}
9696

9797
mbed_watchdog_reset();
@@ -104,7 +104,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
104104
if ((err = fs.mount(&flash)) != 0)
105105
{
106106
DEBUG_ERROR("%s: fs.mount() failed with %d", __FUNCTION__, err);
107-
return err;
107+
return static_cast<int>(OTAError::RP2040_ErrorMount);
108108
}
109109

110110
mbed_watchdog_reset();
@@ -231,9 +231,17 @@ int rp2040_connect_onOTARequest(char const * ota_url)
231231
return static_cast<int>(OTAError::RP2040_HttpDataError);
232232
}
233233

234-
/* Perform the reset to reboot to SFU. */
235234
DEBUG_INFO("%s: %d bytes received", __FUNCTION__, ftell(file));
236235
fclose(file);
236+
237+
/* Unmount the filesystem. */
238+
if ((err = fs.unmount()) != 0)
239+
{
240+
DEBUG_ERROR("%s: fs.unmount() failed with %d", __FUNCTION__, err);
241+
return static_cast<int>(OTAError::RP2040_ErrorUnmount);
242+
}
243+
244+
/* Perform the reset to reboot to SFU. */
237245
mbed_watchdog_trigger_reset();
238246

239247
return static_cast<int>(OTAError::None);

src/utility/ota/OTA.h

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ enum class OTAError : int
4545
RP2040_ErrorOpenUpdateFile = RP2040_OTA_ERROR_BASE - 4,
4646
RP2040_ErrorWriteUpdateFile = RP2040_OTA_ERROR_BASE - 5,
4747
RP2040_ErrorParseHttpHeader = RP2040_OTA_ERROR_BASE - 6,
48+
RP2040_ErrorFlashInit = RP2040_OTA_ERROR_BASE - 7,
49+
RP2040_ErrorMount = RP2040_OTA_ERROR_BASE - 8,
50+
RP2040_ErrorUnmount = RP2040_OTA_ERROR_BASE - 9,
4851
};
4952

5053
/******************************************************************************

0 commit comments

Comments
 (0)