mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-22 07:45:29 +03:00
fix bootloader jump for g4 mcu (#12675)
This commit is contained in:
parent
20747ec3e3
commit
66d7f05448
2 changed files with 36 additions and 11 deletions
|
@ -39,7 +39,7 @@ SECTIONS
|
|||
|
||||
.isr_vector :
|
||||
{
|
||||
. = ALIGN(512);
|
||||
. = ALIGN(4);
|
||||
PROVIDE (isr_vector_table_base = .);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
|
|
|
@ -86,30 +86,55 @@ void systemReset(void)
|
|||
|
||||
void systemResetToBootloader(bootloaderRequestType_e requestType)
|
||||
{
|
||||
UNUSED(requestType);
|
||||
switch (requestType) {
|
||||
case BOOTLOADER_REQUEST_ROM:
|
||||
default:
|
||||
persistentObjectWrite(PERSISTENT_OBJECT_RESET_REASON, RESET_BOOTLOADER_REQUEST_ROM);
|
||||
|
||||
persistentObjectWrite(PERSISTENT_OBJECT_RESET_REASON, RESET_BOOTLOADER_REQUEST_ROM);
|
||||
break;
|
||||
}
|
||||
|
||||
__disable_irq();
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
#define SYSMEMBOOT_VECTOR_TABLE ((uint32_t *)0x1fff0000)
|
||||
#define SYSMEMBOOT_LOADER ((uint32_t *)0x1fff0000)
|
||||
|
||||
typedef void *(*bootJumpPtr)(void);
|
||||
|
||||
typedef void resetHandler_t(void);
|
||||
|
||||
typedef struct isrVector_s {
|
||||
__I uint32_t stackEnd;
|
||||
resetHandler_t *resetHandler;
|
||||
} isrVector_t;
|
||||
|
||||
void systemJumpToBootloader(void)
|
||||
{
|
||||
__SYSCFG_CLK_ENABLE();
|
||||
|
||||
uint32_t bootStack = SYSMEMBOOT_VECTOR_TABLE[0];
|
||||
|
||||
{
|
||||
//DeInit all used peripherals
|
||||
HAL_RCC_DeInit();
|
||||
|
||||
//Disable all system timers and set to default values
|
||||
SysTick->CTRL = 0;
|
||||
SysTick->LOAD = 0;
|
||||
SysTick->VAL = 0;
|
||||
|
||||
//Disable all interrupts
|
||||
__disable_irq();
|
||||
|
||||
//remap system memory
|
||||
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
|
||||
|
||||
//default bootloader call stack routine
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue