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:
@@ -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;
|
||||
|
||||
@@ -492,7 +492,7 @@ const char * FrskyDeviceFirmwareUpdate::flashFirmware(const char * filename)
|
||||
drawProgressScreen(getBasename(filename), STR_DEVICE_RESET, 0, 0);
|
||||
|
||||
/* wait 2s off */
|
||||
watchdogSuspend(2000);
|
||||
watchdogSuspend(1000 /*10s*/);
|
||||
RTOS_WAIT_MS(2000);
|
||||
|
||||
const char * result = doFlashFirmware(filename);
|
||||
@@ -515,7 +515,7 @@ const char * FrskyDeviceFirmwareUpdate::flashFirmware(const char * filename)
|
||||
SPORT_UPDATE_POWER_OFF();
|
||||
|
||||
/* wait 2s off */
|
||||
watchdogSuspend(2000);
|
||||
watchdogSuspend(500 /*5s*/);
|
||||
RTOS_WAIT_MS(2000);
|
||||
telemetryClearFifo();
|
||||
|
||||
@@ -756,7 +756,7 @@ const char * FrskyChipFirmwareUpdate::flashFirmware(const char * filename, bool
|
||||
|
||||
if (wait) {
|
||||
/* wait 2s off */
|
||||
watchdogSuspend(2000);
|
||||
watchdogSuspend(1000 /*10s*/);
|
||||
RTOS_WAIT_MS(2000);
|
||||
}
|
||||
|
||||
@@ -776,7 +776,7 @@ const char * FrskyChipFirmwareUpdate::flashFirmware(const char * filename, bool
|
||||
}
|
||||
|
||||
/* wait 2s off */
|
||||
watchdogSuspend(2000);
|
||||
watchdogSuspend(1000 /*10s*/);
|
||||
RTOS_WAIT_MS(2000);
|
||||
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
|
||||
@@ -195,7 +195,7 @@ const char * MultiFirmwareUpdateDriver::waitForInitialSync(bool& inverted) const
|
||||
sendByte(CRC_EOP);
|
||||
|
||||
getRxByte(byte);
|
||||
wdt_reset();
|
||||
WDG_RESET();
|
||||
|
||||
} while((byte != STK_INSYNC) && --retries);
|
||||
|
||||
@@ -270,7 +270,7 @@ const char * MultiFirmwareUpdateDriver::progPage(uint8_t* buffer, uint16_t size)
|
||||
uint8_t retries = 4;
|
||||
do {
|
||||
getRxByte(byte);
|
||||
wdt_reset();
|
||||
WDG_RESET();
|
||||
} while(!byte && --retries);
|
||||
|
||||
if (!retries || (byte != STK_OK))
|
||||
@@ -298,7 +298,7 @@ const char * MultiFirmwareUpdateDriver::flashFirmware(FIL* file, const char* lab
|
||||
init(inverted);
|
||||
|
||||
/* wait 500ms for power on */
|
||||
watchdogSuspend(500);
|
||||
watchdogSuspend(500 /*5s*/);
|
||||
RTOS_WAIT_MS(500);
|
||||
|
||||
result = waitForInitialSync(inverted);
|
||||
@@ -533,7 +533,7 @@ bool multiFlashFirmware(uint8_t moduleIdx, const char * filename)
|
||||
drawProgressScreen(getBasename(filename), STR_DEVICE_RESET, 0, 0);
|
||||
|
||||
/* wait 2s off */
|
||||
watchdogSuspend(2000);
|
||||
watchdogSuspend(500 /*5s*/);
|
||||
RTOS_WAIT_MS(2000);
|
||||
|
||||
const char * result = driver->flashFirmware(&file, getBasename(filename));
|
||||
@@ -557,7 +557,7 @@ bool multiFlashFirmware(uint8_t moduleIdx, const char * filename)
|
||||
SPORT_UPDATE_POWER_OFF();
|
||||
|
||||
/* wait 2s off */
|
||||
watchdogSuspend(2000);
|
||||
watchdogSuspend(500 /*5s*/);
|
||||
RTOS_WAIT_MS(2000);
|
||||
|
||||
// reset telemetry protocol
|
||||
|
||||
Reference in New Issue
Block a user