Skip to content

Commit 80d9a95

Browse files
committed
STM32H747_manageBootloader: fix corner cases
1 parent e8e47b8 commit 80d9a95

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libraries/STM32H747_System/examples/STM32H747_manageBootloader/STM32H747_manageBootloader.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ void setup() {
153153

154154
if (writeLoader) {
155155
if(availableBootloaderIdentifier.equals("MCUboot Arduino")) {
156-
setupMCUBootOTAData();
157156

158157
Serial.println("\nThe bootloader comes with a set of default keys to evaluate signing and encryption process");
159158
Serial.println("If you load the keys, you will need to upload the future sketches with Security Settings -> Signing + Encryption.");
@@ -163,8 +162,10 @@ void setup() {
163162
Serial.println("\nPlease notice that loading the keys will enable MCUboot Sketch swap. This will increase the sketch update time after the upload.");
164163
Serial.println("A violet LED will blink until the sketch is ready to run.");
165164
Serial.println("Do you want to proceed loading the default keys? Y/[n]");
165+
writeKeys = waitResponse();
166+
} else {
167+
writeKeys = false;
166168
}
167-
writeKeys = waitResponse();
168169
}
169170
applyUpdate(BOOTLOADER_ADDR);
170171
} else {
@@ -333,6 +334,7 @@ void applyUpdate(uint32_t address) {
333334

334335
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_OPTA)
335336
if (writeKeys) {
337+
setupMCUBootOTAData();
336338
flash.program(&enc_priv_key, ENCRYPT_KEY_ADDR, ENCRYPT_KEY_SIZE);
337339
flash.program(&ecdsa_pub_key, SIGNING_KEY_ADDR, SIGNING_KEY_SIZE);
338340
}

0 commit comments

Comments
 (0)