2015-09-02 04:10 AM
Hello,
I am using STM32F401 Nucleo Board. I want go into the bootloader without pins manipulating. According to the many posts, I have seen in the forum. I added this code to my startup_stm32f401xe.s fileReset_Handler:
ldr sp, =_estack /* set stack pointer */
/* Copy the data segment initializers from flash to SRAM */
movs r1, #0
b LoopCopyDataInit
Reboot_Loader:
/* EXPORT Reboot_Loader*/
LDR R0, =0x40021018 /* RCC_APB2ENR*/
LDR R1, =0x00000001 /* ENABLE SYSCFG CLOCK*/
STR R13, [R0, #0]
LDR R0, =0x40010000 /*SYSCFG_MEMRMP*/
LDR R1, =0x00000001 /* MAP ROM AT ZERO*/
STR R1, [R0, #0]
LDR R0, =0x1FFF0000 /* ROM BASE*/
LDR SP,[R0, #0] /*SP @ +0*/
MOV SP,R1
LDR R0,[R0, #4] /* PC @ +4*/
BX R0
and in main.c
I added: extern void Reboot_Loader(void);
blink_led_on();
timer_sleep(500);
blink_led_off();
timer_sleep(500);
HAL_UART_DeInit(&UartHandle);
HAL_DeInit();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
Reboot_Loader();
// NVIC_SystemReset();
But I have !
undefined reference to 'Reboot_Loader' issue? How can I deal with it?
Thanks for all helps you can give!
2015-09-02 08:52 AM
You'd need to EXPORT the symbol with the assembler you are using, so it's a public symbol the linker can associate with the call.
This really isn't the method I've suggested for calling this code.2015-09-03 12:25 AM
Thank you Clive.
Finally , I have used this code and it's working pretty good. But I am curious about the better method you have suggest. Can you tell me what is the other method?#define ApplicationAddress 0x1FFF0000
typedef void (*pFunction)(void);
uint32_t JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
pFunction Jump_To_Boot = (pFunction) JumpAddress;
__set_MSP(*(__IO uint32_t*) ApplicationAddress);
Jump_To_Boot();