Skip to content

Commit 3fe6f7c

Browse files
committed
WiFi: offload firmware to external QSPI
Based on https://github.com/arduino/mbed-os/pull/new/portenta_h7_wifi_on_qspi
1 parent 78f2529 commit 3fe6f7c

File tree

5 files changed

+25575
-1
lines changed

5 files changed

+25575
-1
lines changed

cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/COMPONENT_WHD/whd_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define WLAN_POWER_UP_DELAY_MS 250
2121
#define SDIO_ENUMERATION_TIMEOUT_MS 500
2222

23+
#define USES_RESOURCE_GENERIC_FILESYSTEM
2324

2425
#define BSP_LED1 {GPIOK,{.Pin= GPIO_PIN_5 , .Mode = GPIO_MODE_OUTPUT_PP , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_LOW}}
2526
#define BSP_LED2 {GPIOK,{.Pin= GPIO_PIN_6 , .Mode = GPIO_MODE_OUTPUT_PP , .Pull = GPIO_NOPULL , .Speed= GPIO_SPEED_FREQ_LOW}}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#include "QSPIFBlockDevice.h"
2+
#include "MBRBlockDevice.h"
3+
#include "FATFileSystem.h"
4+
5+
QSPIFBlockDevice root(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000);
6+
mbed::MBRBlockDevice wifi_data(&root, 1);
7+
mbed::MBRBlockDevice other_data(&root, 2);
8+
mbed::FATFileSystem wifi_data_fs("wlan");
9+
mbed::FATFileSystem other_data_fs("fs");
10+
11+
void setup() {
12+
13+
Serial.begin(115200);
14+
while (!Serial);
15+
16+
mbed::MBRBlockDevice::partition(&root, 1, 0x0B, 0, 1024 * 1024 * 8);
17+
mbed::MBRBlockDevice::partition(&root, 2, 0x0B, 1024 * 1024 * 8, 2048 * 1024 * 8);
18+
19+
int err = wifi_data_fs.mount(&wifi_data);
20+
if (err) {
21+
// Reformat if we can't mount the filesystem
22+
// this should only happen on the first boot
23+
Serial.println("No filesystem found, formatting...");
24+
err = wifi_data_fs.reformat(&wifi_data);
25+
}
26+
27+
err = other_data_fs.mount(&other_data);
28+
if (err) {
29+
// Reformat if we can't mount the filesystem
30+
// this should only happen on the first boot
31+
Serial.println("No filesystem found, formatting... ");
32+
err = other_data_fs.reformat(&other_data);
33+
}
34+
35+
DIR *dir;
36+
struct dirent *ent;
37+
38+
if ((dir = opendir("/wlan")) != NULL) {
39+
/* print all the files and directories within directory */
40+
while ((ent = readdir (dir)) != NULL) {
41+
Serial.println(ent->d_name);
42+
String fullname = "/wlan/" + String(ent->d_name);
43+
if (fullname == "/wlan/4343WA1.BIN") {
44+
Serial.println("Firmware found! Force update? [Y/n]");
45+
while (1) {
46+
if (Serial.available()) {
47+
int c = Serial.read();
48+
if (c == 'Y' || c == 'y') {
49+
break;
50+
}
51+
if (c == 'N' || c == 'n') {
52+
return;
53+
}
54+
}
55+
}
56+
}
57+
}
58+
closedir (dir);
59+
}
60+
61+
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);
64+
fclose(fp);
65+
66+
Serial.println("Firmware and certificates updated!");
67+
}
68+
69+
void loop() {
70+
71+
}

0 commit comments

Comments
 (0)