1
1
#include " FlashIAP.h"
2
2
#if defined(ARDUINO_PORTENTA_H7_M7)
3
3
#include " portenta_bootloader.h"
4
+ #include " portenta_lite_bootloader.h"
5
+ #include " portenta_lite_connected_bootloader.h"
4
6
#elif defined(ARDUINO_NICLA_VISION)
5
7
#include " nicla_vision_bootloader.h"
6
8
#endif
@@ -15,6 +17,9 @@ mbed::FlashIAP flash;
15
17
uint32_t bootloader_data_offset = 0x1F000 ;
16
18
uint8_t * bootloader_data = (uint8_t *)(BOOTLOADER_ADDR + bootloader_data_offset);
17
19
20
+ bool video_available = false ;
21
+ bool wifi_available = false ;
22
+
18
23
void setup () {
19
24
Serial.begin (115200 );
20
25
while (!Serial) {}
@@ -33,6 +38,9 @@ void setup() {
33
38
Serial.println (" Has Video output: " + String (bootloader_data[8 ] == 1 ? " Yes" : " No" ));
34
39
Serial.println (" Has Crypto chip: " + String (bootloader_data[9 ] == 1 ? " Yes" : " No" ));
35
40
41
+ video_available = bootloader_data[8 ];
42
+ wifi_available = bootloader_data[5 ];
43
+
36
44
if (availableBootloaderVersion > currentBootloaderVersion) {
37
45
Serial.print (" \n A new bootloader version is available: v" + String (availableBootloaderVersion));
38
46
Serial.println (" (Your version: v" + String (currentBootloaderVersion) + " )" );
@@ -92,6 +100,15 @@ String getClockSource(uint8_t flag) {
92
100
93
101
void applyUpdate (uint32_t address) {
94
102
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
95
112
96
113
flash.init ();
97
114
@@ -116,7 +133,19 @@ void applyUpdate(uint32_t address) {
116
133
}
117
134
118
135
// Program page
136
+ #if defined(ARDUINO_PORTENTA_H7_M7)
137
+ if (video_available) {
119
138
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
120
149
121
150
addr += page_size;
122
151
if (addr >= next_sector) {
0 commit comments