1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

[H7] Boot loader call cleanup

This commit is contained in:
jflyper 2020-02-24 22:24:33 +09:00
parent beef951485
commit 973d3cccc5

View file

@ -128,6 +128,27 @@ void systemResetToBootloader(bootloaderRequestType_e requestType)
NVIC_SystemReset();
}
#define SYSMEMBOOT_VECTOR_TABLE ((uint32_t *)0x1ff09800)
typedef void *(*bootJumpPtr)(void);
void systemJumpToBootloader(void)
{
__SYSCFG_CLK_ENABLE();
uint32_t bootStack = SYSMEMBOOT_VECTOR_TABLE[0];
bootJumpPtr SysMemBootJump = (bootJumpPtr)SYSMEMBOOT_VECTOR_TABLE[1];
__set_MSP(bootStack); //Set the main stack pointer to its default values
SysMemBootJump();
while (1);
}
static uint32_t bootloaderRequest;
void systemCheckResetReason(void)
@ -160,12 +181,5 @@ void systemCheckResetReason(void)
forcedSystemResetWithoutDisablingCaches(); // observed that disabling dcache after cold boot with BOOT pin high causes segfault.
}
void (*SysMemBootJump)(void);
__SYSCFG_CLK_ENABLE();
uint32_t p = (*((uint32_t *) 0x1ff09800));
__set_MSP(p); //Set the main stack pointer to its defualt values
SysMemBootJump = (void (*)(void)) (*((uint32_t *) 0x1ff09804)); // Point the PC to the System Memory reset vector (+4)
SysMemBootJump();
while (1);
systemJumpToBootloader();
}