MAGIC value for powerReason should be stored in RTC backup on Horus (#7096)

- Allows the radio main application to start correctly when coming from an app in RAM
- Refactoring of the `UNEXPECTED_SHUTDOWN()` process
- Saves the RTC battery as BACKUP RAM is not needed on normal shutdown
- On PWR OFF on an ALERT, the radio won't show the next alert before shutting down
- Bootloader flashable through the SD Manager
This commit is contained in:
Bertrand Songis
2019-11-21 11:50:33 +01:00
committed by GitHub
parent 103534bdcf
commit 4cdd17f0d7
41 changed files with 235 additions and 190 deletions
+9 -7
View File
@@ -27,7 +27,7 @@ bool isBootloader(const char * filename)
uint8_t buffer[1024];
UINT count;
if (f_read(&file, buffer, 1024, &count) != FR_OK || count != 1024) {
if (f_read(&file, buffer, sizeof(buffer), &count) != FR_OK || count != sizeof(buffer)) {
return false;
}
@@ -47,18 +47,18 @@ void bootloaderFlash(const char * filename)
unlockFlash();
}
for (int i=0; i<BOOTLOADER_SIZE; i+=1024) {
watchdogSuspend(100/*1s*/);
if (f_read(&file, buffer, 1024, &count) != FR_OK || count != 1024) {
for (int i = 0; i < BOOTLOADER_SIZE; i += 1024) {
watchdogSuspend(1000/*10s*/);
if (f_read(&file, buffer, sizeof(buffer), &count) != FR_OK || count != sizeof(buffer)) {
POPUP_WARNING(STR_SDCARD_ERROR);
break;
}
if (i==0 && !isBootloaderStart(buffer)) {
if (i == 0 && !isBootloaderStart(buffer)) {
POPUP_WARNING(STR_INCOMPATIBLE);
break;
}
for (int j=0; j<1024; j+=FLASH_PAGESIZE) {
flashWrite(CONVERT_UINT_PTR(FIRMWARE_ADDRESS+i+j), (uint32_t *)(buffer+j));
for (int j = 0; j < 1024; j += FLASH_PAGESIZE) {
flashWrite(CONVERT_UINT_PTR(FIRMWARE_ADDRESS + i + j), CONVERT_UINT_PTR(buffer + j));
}
drawProgressScreen("Bootloader", STR_WRITING, i, BOOTLOADER_SIZE);
#if defined(SIMU)
@@ -68,6 +68,8 @@ void bootloaderFlash(const char * filename)
#endif
}
watchdogSuspend(0);
if (unlocked) {
lockFlash();
unlocked = 0;