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 :
|
.isr_vector :
|
||||||
{
|
{
|
||||||
. = ALIGN(512);
|
. = ALIGN(4);
|
||||||
PROVIDE (isr_vector_table_base = .);
|
PROVIDE (isr_vector_table_base = .);
|
||||||
KEEP(*(.isr_vector)) /* Startup code */
|
KEEP(*(.isr_vector)) /* Startup code */
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
|
|
|
@ -86,23 +86,48 @@ void systemReset(void)
|
||||||
|
|
||||||
void systemResetToBootloader(bootloaderRequestType_e requestType)
|
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();
|
__disable_irq();
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SYSMEMBOOT_VECTOR_TABLE ((uint32_t *)0x1fff0000)
|
#define SYSMEMBOOT_VECTOR_TABLE ((uint32_t *)0x1fff0000)
|
||||||
|
#define SYSMEMBOOT_LOADER ((uint32_t *)0x1fff0000)
|
||||||
|
|
||||||
typedef void *(*bootJumpPtr)(void);
|
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)
|
void systemJumpToBootloader(void)
|
||||||
{
|
{
|
||||||
__SYSCFG_CLK_ENABLE();
|
//DeInit all used peripherals
|
||||||
|
HAL_RCC_DeInit();
|
||||||
|
|
||||||
uint32_t bootStack = SYSMEMBOOT_VECTOR_TABLE[0];
|
//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];
|
bootJumpPtr SysMemBootJump = (bootJumpPtr)SYSMEMBOOT_VECTOR_TABLE[1];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue