@@ -80,7 +80,8 @@ void setup() {
80
80
81
81
Serial.println (" Do you want to perform a full erase of the QSPI flash before proceeding? Y/[n]" );
82
82
Serial.println (" Note: Full flash erase can take up to one minute." );
83
- if (true == waitResponse ()) {
83
+ bool fullErase = waitResponse ();
84
+ if (fullErase == true ) {
84
85
Serial.println (" Full erase started, please wait..." );
85
86
root->erase (0x0 , root->size ());
86
87
Serial.println (" Full erase completed." );
@@ -109,7 +110,7 @@ void setup() {
109
110
}
110
111
111
112
bool restore = true ;
112
- if (reformat) {
113
+ if (reformat || fullErase ) {
113
114
Serial.println (" \n Do you want to restore the WiFi firmware and certificates? Y/[n]" );
114
115
restore = waitResponse ();
115
116
}
@@ -118,6 +119,10 @@ void setup() {
118
119
flashWiFiFirmwareAndCertificates ();
119
120
}
120
121
122
+ if (fullErase && restore) {
123
+ flashWiFiFirmwareMapped ();
124
+ }
125
+
121
126
reformat = true ;
122
127
if (!ota_data_fs.mount (&ota_data)) {
123
128
Serial.println (" \n Partition 2 already contains a filesystem, do you want to reformat it? Y/[n]" );
@@ -161,10 +166,11 @@ void setup() {
161
166
Serial.println (" It's now safe to reboot or disconnect your board." );
162
167
}
163
168
169
+ const uint32_t file_size = 421098 ;
170
+ extern const unsigned char wifi_firmware_image_data[];
171
+
164
172
void flashWiFiFirmwareAndCertificates () {
165
- extern const unsigned char wifi_firmware_image_data[];
166
173
FILE* fp = fopen (" /wlan/4343WA1.BIN" , " wb" );
167
- const uint32_t file_size = 421098 ;
168
174
uint32_t chunck_size = 1024 ;
169
175
uint32_t byte_count = 0 ;
170
176
@@ -203,6 +209,26 @@ void flashWiFiFirmwareAndCertificates() {
203
209
fclose (fp);
204
210
}
205
211
212
+ void flashWiFiFirmwareMapped () {
213
+ uint32_t chunck_size = 1024 ;
214
+ uint32_t byte_count = 0 ;
215
+ const uint32_t offset = 15 * 1024 * 1024 + 1024 * 512 ;
216
+
217
+ Serial.println (" Flashing memory mapped WiFi firmware" );
218
+ printProgress (byte_count, file_size, 10 , true );
219
+ while (byte_count < file_size) {
220
+ if (byte_count + chunck_size > file_size)
221
+ chunck_size = file_size - byte_count;
222
+ int ret = root->program (wifi_firmware_image_data, offset + byte_count, chunck_size);
223
+ if (ret != 0 ) {
224
+ Serial.println (" Error writing memory mapped firmware" );
225
+ break ;
226
+ }
227
+ byte_count += chunck_size;
228
+ printProgress (byte_count, file_size, 10 , false );
229
+ }
230
+ }
231
+
206
232
void loop () {
207
233
208
234
}
0 commit comments