Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6d9c5d9

Browse files
committed
QSPIFormat: add function to restore memory mapped firmware
1 parent 750849f commit 6d9c5d9

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

‎libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ void setup() {
8080

8181
Serial.println("Do you want to perform a full erase of the QSPI flash before proceeding? Y/[n]");
8282
Serial.println("Note: Full flash erase can take up to one minute.");
83-
if (true == waitResponse()) {
83+
bool fullErase = waitResponse();
84+
if (fullErase == true) {
8485
Serial.println("Full erase started, please wait...");
8586
root->erase(0x0, root->size());
8687
Serial.println("Full erase completed.");
@@ -109,7 +110,7 @@ void setup() {
109110
}
110111

111112
bool restore = true;
112-
if (reformat) {
113+
if (reformat || fullErase) {
113114
Serial.println("\nDo you want to restore the WiFi firmware and certificates? Y/[n]");
114115
restore = waitResponse();
115116
}
@@ -118,6 +119,10 @@ void setup() {
118119
flashWiFiFirmwareAndCertificates();
119120
}
120121

122+
if (fullErase && restore) {
123+
flashWiFiFirmwareMapped();
124+
}
125+
121126
reformat = true;
122127
if (!ota_data_fs.mount(&ota_data)) {
123128
Serial.println("\nPartition 2 already contains a filesystem, do you want to reformat it? Y/[n]");
@@ -161,10 +166,11 @@ void setup() {
161166
Serial.println("It's now safe to reboot or disconnect your board.");
162167
}
163168

169+
const uint32_t file_size = 421098;
170+
extern const unsigned char wifi_firmware_image_data[];
171+
164172
void flashWiFiFirmwareAndCertificates() {
165-
extern const unsigned char wifi_firmware_image_data[];
166173
FILE* fp = fopen("/wlan/4343WA1.BIN", "wb");
167-
const uint32_t file_size = 421098;
168174
uint32_t chunck_size = 1024;
169175
uint32_t byte_count = 0;
170176

@@ -203,6 +209,26 @@ void flashWiFiFirmwareAndCertificates() {
203209
fclose(fp);
204210
}
205211

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+
206232
void loop() {
207233

208234
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /