1818*/
1919
2020#include " SFU.h"
21- #include < BlockDevice.h>
22- #include < MBRBlockDevice.h>
23- #include " FATFileSystem.h"
2421#include < Arduino_DebugUtils.h>
2522#include < WiFiC3.h>
2623#include < WiFiSSLClient.h>
@@ -32,10 +29,6 @@ const unsigned char SFU[0x20000] __attribute__ ((section(".second_stage_ota"), u
3229 #include " c33.h"
3330};
3431
35- BlockDevice* block_device = BlockDevice::get_default_instance();
36- MBRBlockDevice mbr (block_device, 1 );
37- FATFileSystem fs (" ota" );
38-
3932/* Original code: http://stackoverflow.com/questions/2616011/easy-way-to-parse-a-url-in-c-cross-platform */
4033#include < string>
4134#include < algorithm>
@@ -81,16 +74,10 @@ void URI::parse(const string& url_s)
8174 query_.assign (query_i, url_s.end ());
8275}
8376
84- int SFU::download (const char * ota_url) {
77+ int SFU::download (const char * ota_path, const char * ota_url) {
8578 int err = -1 ;
8679
87- if ((err = fs.reformat (&mbr)) != 0 )
88- {
89- DEBUG_ERROR (" %s: fs.reformat() failed with %d" , __FUNCTION__, err);
90- return static_cast <int >(OTAError::PORTENTA_C33_ErrorReformat);
91- }
92-
93- FILE * file = fopen (" /ota/UPDATE.BIN.OTA" , " wb" );
80+ FILE * file = fopen (ota_path, " wb" );
9481 if (!file)
9582 {
9683 DEBUG_ERROR (" %s: fopen() failed" , __FUNCTION__);
@@ -203,12 +190,5 @@ int SFU::download(const char* ota_url) {
203190 DEBUG_INFO (" %s: %d bytes received" , __FUNCTION__, ftell (file));
204191 fclose (file);
205192
206- /* Unmount the filesystem. */
207- if ((err = fs.unmount ()) != 0 )
208- {
209- DEBUG_ERROR (" %s: fs.unmount() failed with %d" , __FUNCTION__, err);
210- return static_cast <int >(OTAError::PORTENTA_C33_ErrorUnmount);
211- }
212-
213193 return static_cast <int >(OTAError::None);
214194}
0 commit comments