AnsweredAssumed Answered

STM32 booloader

Question asked by Giu S on Aug 28, 2017
Latest reply on Aug 29, 2017 by Giu S

Hello to all.

I'm new user in STM32 and I need to do a CAN bootloader. Only software bootloader! I understand how I can modify the linker script to add the boot region. But my problem is how to jump at the startup into the bootloader or in the main. I think that I need to modify the startup_stm32f091xc.s file but I don't know how.

So what I want is: at startup in the assemby code I want to decide if I have to Jump in the boot function or in the main, and the startup code need to move in the boot region to avoid the delete during the flash program with the bootloader.


I think that the code that I have to modify is the follow, but why? Could somone explain to me how? Thank you very much.


.section .text.Reset_Handler
.weak Reset_Handler
.type Reset_Handler, %function

ldr r0, =_estack
mov sp, r0 /* set stack pointer */

/* Copy the data segment initializers from flash to SRAM */
movs r1, #0
b LoopCopyDataInit

ldr r3, =_sidata
ldr r3, [r3, r1]
str r3, [r0, r1]
adds r1, r1, #4

ldr r0, =_sdata
ldr r3, =_edata
adds r2, r0, r1
cmp r2, r3
bcc CopyDataInit
ldr r2, =_sbss
b LoopFillZerobss
/* Zero fill the bss segment. */
movs r3, #0
str r3, [r2]
adds r2, r2, #4

ldr r3, = _ebss
cmp r2, r3
bcc FillZerobss

/* Call the clock system intitialization function.*/
bl SystemInit
/* Call static constructors */
bl __libc_init_array
/* Call the application's entry point.*/
bl main

b LoopForever

.size Reset_Handler, .-Reset_Handler