Bootloader: always treat initial state as tainted. Firmware: mark boot state as tainted on boot. (#558)
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
#include <api-hal-boot.h>
|
||||
#include <stm32wbxx_ll_rtc.h>
|
||||
|
||||
#define BOOT_REQUEST_NONE 0x00000000
|
||||
// Boot request enum
|
||||
#define BOOT_REQUEST_TAINTED 0x00000000
|
||||
#define BOOT_REQUEST_CLEAN 0xDADEDADE
|
||||
#define BOOT_REQUEST_DFU 0xDF00B000
|
||||
|
||||
void api_hal_boot_init() {
|
||||
LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_TAINTED);
|
||||
}
|
||||
|
||||
void api_hal_boot_set_mode(ApiHalBootMode mode) {
|
||||
if (mode == ApiHalBootModeNormal) {
|
||||
LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_NONE);
|
||||
LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_CLEAN);
|
||||
} else if (mode == ApiHalBootModeDFU) {
|
||||
LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_DFU);
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#include <api-hal.h>
|
||||
|
||||
void api_hal_init() {
|
||||
api_hal_boot_init();
|
||||
FURI_LOG_I("FURI_HAL", "BOOT OK");
|
||||
api_hal_version_init();
|
||||
FURI_LOG_I("FURI_HAL", "VERSION OK");
|
||||
api_hal_delay_init();
|
||||
|
Reference in New Issue
Block a user