2017-08-28 07:53 AM
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, %functionReset_Handler: ldr r0, =_estack mov sp, r0 /* set stack pointer *//* Copy the data segment initializers from flash to SRAM */
movs r1, #0 b LoopCopyDataInitCopyDataInit:
ldr r3, =_sidata ldr r3, [r3, r1] str r3, [r0, r1] adds r1, r1, #4LoopCopyDataInit:
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, #4LoopFillZerobss: 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 mainLoopForever:
b LoopForever.size Reset_Handler, .-Reset_Handler2017-08-28 09:08 AM
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.
2017-08-29 01:17 AM
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.