Skip to content

Commit 0cca36f

Browse files
committed
Fix BLUpdate sketch to add Portenta Lite and Connected bootloaders
1 parent 78d1e52 commit 0cca36f

File tree

4 files changed

+30422
-9034
lines changed

4 files changed

+30422
-9034
lines changed

libraries/STM32H747_System/examples/STM32H747_updateBootloader/STM32H747_updateBootloader.ino

+29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "FlashIAP.h"
22
#if defined(ARDUINO_PORTENTA_H7_M7)
33
#include "portenta_bootloader.h"
4+
#include "portenta_lite_bootloader.h"
5+
#include "portenta_lite_connected_bootloader.h"
46
#elif defined(ARDUINO_NICLA_VISION)
57
#include "nicla_vision_bootloader.h"
68
#endif
@@ -15,6 +17,9 @@ mbed::FlashIAP flash;
1517
uint32_t bootloader_data_offset = 0x1F000;
1618
uint8_t* bootloader_data = (uint8_t*)(BOOTLOADER_ADDR + bootloader_data_offset);
1719

20+
bool video_available = false;
21+
bool wifi_available = false;
22+
1823
void setup() {
1924
Serial.begin(115200);
2025
while (!Serial) {}
@@ -33,6 +38,9 @@ void setup() {
3338
Serial.println("Has Video output: " + String(bootloader_data[8] == 1 ? "Yes" : "No"));
3439
Serial.println("Has Crypto chip: " + String(bootloader_data[9] == 1 ? "Yes" : "No"));
3540

41+
video_available = bootloader_data[8];
42+
wifi_available = bootloader_data[5];
43+
3644
if (availableBootloaderVersion > currentBootloaderVersion) {
3745
Serial.print("\nA new bootloader version is available: v" + String(availableBootloaderVersion));
3846
Serial.println(" (Your version: v" + String(currentBootloaderVersion) + ")");
@@ -92,6 +100,15 @@ String getClockSource(uint8_t flag) {
92100

93101
void applyUpdate(uint32_t address) {
94102
long len = bootloader_mbed_bin_len;
103+
#if defined(ARDUINO_PORTENTA_H7_M7)
104+
if (!video_available) {
105+
if (wifi_available) {
106+
len = bootloader_mbed_lite_connected_bin_len;
107+
} else {
108+
len = bootloader_mbed_lite_bin_len;
109+
}
110+
}
111+
#endif
95112

96113
flash.init();
97114

@@ -116,7 +133,19 @@ void applyUpdate(uint32_t address) {
116133
}
117134

118135
// Program page
136+
#if defined(ARDUINO_PORTENTA_H7_M7)
137+
if (video_available) {
119138
flash.program(&bootloader_mbed_bin[page_size * pages_flashed], addr, page_size);
139+
} else {
140+
if (wifi_available) {
141+
flash.program(&bootloader_mbed_lite_connected_bin[page_size * pages_flashed], addr, page_size);
142+
} else {
143+
flash.program(&bootloader_mbed_lite_bin[page_size * pages_flashed], addr, page_size);
144+
}
145+
}
146+
#else
147+
flash.program(&bootloader_mbed_bin[page_size * pages_flashed], addr, page_size);
148+
#endif
120149

121150
addr += page_size;
122151
if (addr >= next_sector) {

0 commit comments

Comments
 (0)