cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 booloader

Giu S
Associate II
Posted on August 28, 2017 at 16:53

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

Reset_Handler:

ldr r0, =_estack

mov sp, r0 /* set stack pointer */

/* Copy the data segment initializers from flash to SRAM */

movs r1, #0

b LoopCopyDataInit

CopyDataInit:

ldr r3, =_sidata

ldr r3, [r3, r1]

str r3, [r0, r1]

adds r1, r1, #4

LoopCopyDataInit:

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. */

FillZerobss:

movs r3, #0

str r3, [r2]

adds r2, r2, #4

LoopFillZerobss:

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

LoopForever:

b LoopForever

.size Reset_Handler, .-Reset_Handler
2 REPLIES 2
Posted on August 28, 2017 at 18:08

Review IAP examples

If the linker scripts for the loader and app describe their own unique areas in Flash, none of this code needs changing.

What you'll need to address on the app side is the relocation of the vector table to RAM, and mapping of RAM into the zero memory address space. You might want to carve 0xC0 bytes of RAM out of the front of the space described in the linker script, ie 0x200000C0 starting address.

Either way, review the array of threads on this topic, and the IAP examples.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 29, 2017 at 08:17

Thnk you for your answer, but I have some difficult to understand what do you mean. Could you explain better what I have to do? Thank you very much.