Skip to content

Commit 0e386a1

Browse files
committed
Temp - Remove later - erase flash within OTA handler.
1 parent 92168d0 commit 0e386a1

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/AIoTC_Config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
6363
# define DEBUG_VERBOSE(fmt, ...)
6464
# else
65-
# define DEBUG_VERBOSE(fmt, ...) //Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
65+
# define DEBUG_VERBOSE(fmt, ...) Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
6666
# endif
6767
#endif
6868

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

+27-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929

3030
#include <SFU.h>
3131

32+
#include "mbed.h"
33+
#include "FATFileSystem.h"
34+
#include "FlashIAPBlockDevice.h"
35+
3236
/******************************************************************************
3337
* FUNCTION DEFINITION
3438
******************************************************************************/
@@ -82,7 +86,28 @@ int rp2040_connect_onOTARequest(char const * ota_url)
8286
{
8387
mbed_watchdog_reset();
8488

85-
SFU::begin();
89+
//SFU::begin();
90+
91+
int err = -1;
92+
FlashIAPBlockDevice flash(XIP_BASE + 0xF00000, 0x100000);
93+
if ((err = flash.init()) < 0)
94+
{
95+
DEBUG_ERROR("%s: flash.init() failed with %d", __FUNCTION__, err);
96+
return err;
97+
}
98+
99+
mbed_watchdog_reset();
100+
101+
flash.erase(XIP_BASE + 0xF00000, 0x100000);
102+
103+
mbed_watchdog_reset();
104+
105+
mbed::FATFileSystem fs("ota");
106+
if ((err = fs.mount(&flash)) != 0)
107+
{
108+
DEBUG_ERROR("%s: fs.mount() failed with %d", __FUNCTION__, err);
109+
return err;
110+
}
86111

87112
mbed_watchdog_reset();
88113

@@ -199,6 +224,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)
199224
}
200225

201226
bytes_received++;
227+
DEBUG_VERBOSE("%d", bytes_received);
202228
}
203229
}
204230

0 commit comments

Comments
 (0)