@@ -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);
0 commit comments