11#include <rusefi/expected.h>
17#elif defined(STM32F7XX)
19#elif defined(STM32H7XX)
34#ifndef ALLOW_JUMP_WITH_IGNITION_VOLTAGE
36#define ALLOW_JUMP_WITH_IGNITION_VOLTAGE TRUE
40#if !ALLOW_JUMP_WITH_IGNITION_VOLTAGE
42 criticalError(
"Not allowed with ignition power");
51 RCC->AHB1ENR &= ~(RCC_AHB1ENR_USB1OTGHSEN | RCC_AHB1ENR_USB2OTGFSEN);
62 *((
unsigned long *)0x2001FFF0) = 0xDEADBEEF;
100 FLASH_Handle.
BORLevel = (uint32_t)BORValue;
111 if (status != HAL_OK) {
121 static WDGConfig wdgcfg;
122 wdgcfg.pr = STM32_IWDG_PR_64;
123 wdgcfg.rlr = STM32_IWDG_RL((uint32_t)((32.768f / 64.0f) * timeoutMs));
124#if STM32_IWDG_IS_WINDOWED
131 efiPrintf(
"Enabling 'debug freeze' watchdog feature...");
133 DBGMCU->APB4FZ1 |= DBGMCU_APB4FZ1_DBG_IWDG1;
135 DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_IWDG_STOP;
139 static bool isStarted =
false;
141 efiPrintf(
"Starting watchdog with timeout %d ms...", timeoutMs);
142 wdgStart(&WDGD1, &wdgcfg);
145 efiPrintf(
"Changing watchdog timeout to %d ms...", timeoutMs);
147 wdg_lld_start(&WDGD1);
158 efiPrintf(
"[dev] wd %d", resetMs);
165 static Timer lastTimeWasReset;
171 lastTimeWasReset.reset();
187 uint32_t *uid = ((uint32_t *)UID_BASE);
188 return uid[0] + uid[1] + uid[2];
196#ifndef EFI_BOOTLOADER
206#if CH_DBG_ENABLE_STACK_CHECK
210 otp->activeStack = r13;
213 if (ch0.dbg.isr_cnt > 0) {
217 remainingStack = (int)(r13 - 1) - (int)otp->wabase;
219 otp->remainingStack = remainingStack;
220 return remainingStack;
232 return ((DBGMCU->IDCODE & DBGMCU_IDCODE_DEV_ID_Msk) == 0x419);
239 palEnableLineEvent(PAL_LINE(GPIOA, 0), PAL_EVENT_MODE_RISING_EDGE);
249 PWR->CSR |= PWR_CSR_EWUP;
253 PWR->CR |= PWR_CR_CWUF;
257 PWR->CSR2 |= PWR_CSR2_EWUP1;
258 PWR->CR2 |= PWR_CR2_CWUPF1;
263 PWR->WKUPEPR = PWR_WKUPEPR_WKUPEN1;
266 PWR->WKUPCR = 0xFFFFFFFF;
struct port_intctx intctx_t
Non-volatile backup-RAM registers support.
TunerStudioOutputChannels outputChannels
static EngineAccessor engine
HAL_StatusTypeDef HAL_FLASH_OB_Launch(void)
Launch the option byte loading.
HAL_StatusTypeDef HAL_FLASH_OB_Lock(void)
Lock the FLASH Option Control Registers access.
HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void)
Unlock the FLASH Option Control Registers access.
HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit)
Program option bytes.
void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit)
Get the Option byte configuration.
UNUSED(samplingTimeSeconds)
bool SharedParamsWriteByIndex(uint32_t idx, uint8_t value)
Writes a data byte to the shared parameter buffer at the specified index.
void SharedParamsInit(void)
Initializes the shared RAM parameters module.
void setWatchdogResetPeriod(int resetMs)
BOR_Level_t BOR_Get(void)
static efitimems_t watchdogResetPeriodMs
BOR_Result_t BOR_Set(BOR_Level_t BORValue)
int getRemainingStack(thread_t *otp)
void startWatchdog(int timeoutMs)
uint32_t __main_stack_base__
PUBLIC_API_WEAK void boardPrepareForStop()
void boardPreparePA0ForStandby()
void jump_to_bootloader()
PUBLIC_API_WEAK void boardPrepareForStandby()
static void reset_and_jump(void)
static const efitimems_t watchdogCounterResetDelay
Header file of FLASH HAL module.
Header file of FLASH HAL module.
Header file of FLASH HAL module.
FLASH Option Bytes Program structure definition.