Skip to content

Commit b15972f

Browse files
committed
SFU: Remove filesystem and block device dependency from download function
1 parent 51bd3b1 commit b15972f

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

libraries/SFU/src/SFU.cpp

+2-22
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
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
}

libraries/SFU/src/SFU.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ enum class OTAError : int
3737
PORTENTA_C33_ErrorParseHttpHeader = PORTENTA_C33_OTA_ERROR_BASE - 6,
3838
PORTENTA_C33_ErrorFlashInit = PORTENTA_C33_OTA_ERROR_BASE - 7,
3939
PORTENTA_C33_ErrorReformat = PORTENTA_C33_OTA_ERROR_BASE - 8,
40-
PORTENTA_C33_ErrorUnmount = PORTENTA_C33_OTA_ERROR_BASE - 9,
4140
};
4241

4342
class SFU {
4443
public:
4544
static int begin() {};
46-
static int download(const char* url);
45+
static int download(const char* ota_path, const char* ota_url);
4746
static int apply() { NVIC_SystemReset(); };
4847
};
4948

0 commit comments

Comments
 (0)