Skip to content

Commit 0051943

Browse files
committed
WiFi: make external fw check more reliable
1 parent c3d0856 commit 0051943

File tree

3 files changed

+23
-25468
lines changed

3 files changed

+23
-25468
lines changed

libraries/WiFi/examples/PortentaWiFiFirmwareUpdater/PortentaWiFiFirmwareUpdater.ino

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
#include "QSPIFBlockDevice.h"
22
#include "MBRBlockDevice.h"
33
#include "FATFileSystem.h"
4+
#include "wiced_resource.h"
45

56
QSPIFBlockDevice root(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000);
67
mbed::MBRBlockDevice wifi_data(&root, 1);
78
mbed::MBRBlockDevice other_data(&root, 2);
89
mbed::FATFileSystem wifi_data_fs("wlan");
910
mbed::FATFileSystem other_data_fs("fs");
1011

12+
long getFileSize(FILE *fp) {
13+
fseek(fp, 0, SEEK_END);
14+
int size = ftell(fp);
15+
fseek(fp, 0, SEEK_SET);
16+
17+
return size;
18+
}
19+
1120
void setup() {
1221

1322
Serial.begin(115200);
@@ -46,6 +55,7 @@ void setup() {
4655
if (Serial.available()) {
4756
int c = Serial.read();
4857
if (c == 'Y' || c == 'y') {
58+
wifi_data_fs.reformat(&wifi_data);
4959
break;
5060
}
5161
if (c == 'N' || c == 'n') {
@@ -59,10 +69,13 @@ void setup() {
5969
}
6070

6171
extern const unsigned char wifi_firmware_image_data[];
62-
FILE* fp = fopen("/wlan/4343WA1.BIN", "w");
63-
fwrite(wifi_firmware_image_data, 420690, 1, fp);
72+
extern const resource_hnd_t wifi_firmware_image;
73+
FILE* fp = fopen("/wlan/4343WA1.BIN", "wb");
74+
int ret = fwrite(wifi_firmware_image_data, 421098, 1, fp);
6475
fclose(fp);
6576

77+
Serial.println(ret);
78+
Serial.println(wifi_firmware_image.size);
6679
Serial.println("Firmware and certificates updated!");
6780
}
6881

0 commit comments

Comments
 (0)