18
18
*/
19
19
20
20
#include " SFU.h"
21
- #include < BlockDevice.h>
22
- #include < MBRBlockDevice.h>
23
- #include " FATFileSystem.h"
24
21
#include < Arduino_DebugUtils.h>
25
22
#include < WiFiC3.h>
26
23
#include < WiFiSSLClient.h>
@@ -32,10 +29,6 @@ const unsigned char SFU[0x20000] __attribute__ ((section(".second_stage_ota"), u
32
29
#include " c33.h"
33
30
};
34
31
35
- BlockDevice* block_device = BlockDevice::get_default_instance();
36
- MBRBlockDevice mbr (block_device, 1 );
37
- FATFileSystem fs (" ota" );
38
-
39
32
/* Original code: http://stackoverflow.com/questions/2616011/easy-way-to-parse-a-url-in-c-cross-platform */
40
33
#include < string>
41
34
#include < algorithm>
@@ -81,16 +74,10 @@ void URI::parse(const string& url_s)
81
74
query_.assign (query_i, url_s.end ());
82
75
}
83
76
84
- int SFU::download (const char * ota_url) {
77
+ int SFU::download (const char * ota_path, const char * ota_url) {
85
78
int err = -1 ;
86
79
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" );
94
81
if (!file)
95
82
{
96
83
DEBUG_ERROR (" %s: fopen() failed" , __FUNCTION__);
@@ -203,12 +190,5 @@ int SFU::download(const char* ota_url) {
203
190
DEBUG_INFO (" %s: %d bytes received" , __FUNCTION__, ftell (file));
204
191
fclose (file);
205
192
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
-
213
193
return static_cast <int >(OTAError::None);
214
194
}
0 commit comments