mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 06:15:16 +03:00
Reworked reboot flags for F4 partially (#5193)
This commit is contained in:
parent
07cce64572
commit
aede46288b
13 changed files with 118 additions and 171 deletions
|
@ -39,18 +39,43 @@ void systemReset(void)
|
|||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
PERSISTENT uint32_t bootloaderRequest = 0;
|
||||
#define BOOTLOADER_REQUEST_COOKIE 0xDEADBEEF
|
||||
|
||||
void systemResetToBootloader(void)
|
||||
{
|
||||
if (mpuResetFn) {
|
||||
mpuResetFn();
|
||||
}
|
||||
|
||||
*((uint32_t *)0x2001FFFC) = 0xDEADBEEF; // 128KB SRAM STM32F4XX
|
||||
bootloaderRequest = BOOTLOADER_REQUEST_COOKIE;
|
||||
|
||||
__disable_irq();
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
typedef void resetHandler_t(void);
|
||||
|
||||
typedef struct isrVector_s {
|
||||
__I uint32_t stackEnd;
|
||||
resetHandler_t *resetHandler;
|
||||
} isrVector_t;
|
||||
|
||||
void checkForBootLoaderRequest(void)
|
||||
{
|
||||
if (bootloaderRequest != BOOTLOADER_REQUEST_COOKIE) {
|
||||
return;
|
||||
}
|
||||
|
||||
bootloaderRequest = 0;
|
||||
|
||||
extern isrVector_t system_isr_vector_table_base;
|
||||
|
||||
__set_MSP(system_isr_vector_table_base.stackEnd);
|
||||
system_isr_vector_table_base.resetHandler();
|
||||
while (1);
|
||||
}
|
||||
|
||||
void enableGPIOPowerUsageAndNoiseReductions(void)
|
||||
{
|
||||
|
||||
|
@ -160,8 +185,6 @@ bool isMPUSoftReset(void)
|
|||
|
||||
void systemInit(void)
|
||||
{
|
||||
checkForBootLoaderRequest();
|
||||
|
||||
SetSysClock();
|
||||
|
||||
// Configure NVIC preempt/priority groups
|
||||
|
@ -185,19 +208,3 @@ void systemInit(void)
|
|||
// SysTick
|
||||
SysTick_Config(SystemCoreClock / 1000);
|
||||
}
|
||||
|
||||
void(*bootJump)(void);
|
||||
void checkForBootLoaderRequest(void)
|
||||
{
|
||||
if (*((uint32_t *)0x2001FFFC) == 0xDEADBEEF) {
|
||||
|
||||
*((uint32_t *)0x2001FFFC) = 0x0;
|
||||
|
||||
__enable_irq();
|
||||
__set_MSP(*((uint32_t *)0x1FFF0000));
|
||||
|
||||
bootJump = (void(*)(void))(*((uint32_t *) 0x1FFF0004));
|
||||
bootJump();
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue