[Bootloader] Enhance Global Stability

This commit is contained in:
Lisra-git
2023-04-07 23:58:28 +02:00
committed by Yaya-Cout
parent b4820d52e4
commit 0916996121
3 changed files with 61 additions and 53 deletions

View File

@@ -152,7 +152,10 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
* We do it before switching to USB application to redraw the battery
* pictogram. */
updateBatteryState();
if (switchTo(usbConnectedAppSnapshot())) {
if (GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
// If we are in exam mode, we don't switch to usb connected app
didProcessEvent = true;
} else if (switchTo(usbConnectedAppSnapshot())) {
Ion::USB::DFU(true);
// Update LED when exiting DFU mode
Ion::LED::updateColorWithPlugAndCharge();

View File

@@ -72,7 +72,7 @@ public:
constexpr static const char * aboutMessage4 = "and select the OS";
constexpr static const char * aboutMessage5 = "to boot.";
constexpr static const char * bootloaderVersion = "Version 1.0.4 - FREED0M.20.4";
constexpr static const char * bootloaderVersion = "Version 1.0.5 - FREED0M.20.4";
//USB NAMES
constexpr static const char * usbUpsilonBootloader = "Upsilon Bootloader";

View File

@@ -78,11 +78,9 @@ uint8_t SlotsExamMode::FetchSlotExamMode(const char * version, const char * Slot
return examFetch15(start, end);
} else if (strcmp("16.9.0", version) > 0) {
return examFetch16(start, end);
}
else if (strcmp("19.0.0", version) > 0) {
} else if (strcmp("19.0.0", version) > 0) {
return examFetch1718(start, end);
}
else {
} else {
return examFetch19(start, end);
}
}
@@ -157,11 +155,18 @@ uint8_t SlotsExamMode::examFetch19(uint32_t start, uint32_t end) {
uint16_t* start16 = (uint16_t*)start;
uint16_t* end16 = (uint16_t*)end;
while (start16 + 1 <= end16 && *start16 != 0xFFFF) {
start16++;
for (uint16_t* i = end16 - 2; i > start16; i--) {
if (*i != 0xFFFF) {
uint8_t highByte = *i >> 8;
uint8_t lowByte = *i & 0xFF;
if (highByte > lowByte) {
return highByte;
}
else {
return lowByte;
}
}
}
return *(start16 - 1) >> 8;
}
uint32_t SlotsExamMode::getSlotAStartExamAddress(int ExamVersion) {