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

Appearance settings

Commit 4ceaad7

Browse filesBrowse files
authored
Merge pull request #1062 from pennam/formatter-2
QSPIFormat: add function to restore memory mapped firmware
2 parents 142f272 + 6d9c5d9 commit 4ceaad7
Copy full SHA for 4ceaad7

File tree

1 file changed

+36
-7
lines changed
Filter options

1 file changed

+36
-7
lines changed

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

Copy file name to clipboardExpand all lines: libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino
+36-7Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ void setup() {
7979
}
8080

8181
Serial.println("Do you want to perform a full erase of the QSPI flash before proceeding? Y/[n]");
82-
if (true == waitResponse()) {
82+
Serial.println("Note: Full flash erase can take up to one minute.");
83+
bool fullErase = waitResponse();
84+
if (fullErase == true) {
85+
Serial.println("Full erase started, please wait...");
8386
root->erase(0x0, root->size());
87+
Serial.println("Full erase completed.");
8488
} else {
8589
// Erase only the first sector containing the MBR
8690
root->erase(0x0, root->get_erase_size());
@@ -93,7 +97,7 @@ void setup() {
9397
// use space from 15.5MB to 16 MB for another fw, memory mapped
9498

9599
bool reformat = true;
96-
if(!wifi_data_fs.mount(&wifi_data)) {
100+
if (!wifi_data_fs.mount(&wifi_data)) {
97101
Serial.println("\nPartition 1 already contains a filesystem, do you want to reformat it? Y/[n]");
98102
wifi_data_fs.unmount();
99103

@@ -106,7 +110,7 @@ void setup() {
106110
}
107111

108112
bool restore = true;
109-
if (reformat) {
113+
if (reformat || fullErase) {
110114
Serial.println("\nDo you want to restore the WiFi firmware and certificates? Y/[n]");
111115
restore = waitResponse();
112116
}
@@ -115,8 +119,12 @@ void setup() {
115119
flashWiFiFirmwareAndCertificates();
116120
}
117121

122+
if (fullErase && restore) {
123+
flashWiFiFirmwareMapped();
124+
}
125+
118126
reformat = true;
119-
if(!ota_data_fs.mount(&ota_data)) {
127+
if (!ota_data_fs.mount(&ota_data)) {
120128
Serial.println("\nPartition 2 already contains a filesystem, do you want to reformat it? Y/[n]");
121129
ota_data_fs.unmount();
122130

@@ -140,7 +148,7 @@ void setup() {
140148
}
141149

142150
reformat = true;
143-
if(!user_data_fs->mount(&user_data)) {
151+
if (!user_data_fs->mount(&user_data)) {
144152
Serial.println("\nPartition 4 already contains a filesystem, do you want to reformat it? Y/[n]");
145153
user_data_fs->unmount();
146154

@@ -158,10 +166,11 @@ void setup() {
158166
Serial.println("It's now safe to reboot or disconnect your board.");
159167
}
160168

169+
const uint32_t file_size = 421098;
170+
extern const unsigned char wifi_firmware_image_data[];
171+
161172
void flashWiFiFirmwareAndCertificates() {
162-
extern const unsigned char wifi_firmware_image_data[];
163173
FILE* fp = fopen("/wlan/4343WA1.BIN", "wb");
164-
const uint32_t file_size = 421098;
165174
uint32_t chunck_size = 1024;
166175
uint32_t byte_count = 0;
167176

@@ -200,6 +209,26 @@ void flashWiFiFirmwareAndCertificates() {
200209
fclose(fp);
201210
}
202211

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+
203232
void loop() {
204233

205234
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.