AnsweredAssumed Answered

Custom Bootloader on STM32F0

Question asked by schneider.damian.001 on Oct 9, 2016
Latest reply on Oct 24, 2016 by Frank Voorburg

I am trying to write a custom bootloader for the STM32F030XX to upload a firmware through a wirless module (NRF24L01). I already wrote some code handling the upload but I am stuck at how to manage bootloader and user code startup. 
I am no expert in this so please excuse any wrong assumptions.
What I want to do is decide which program to run bootloader or user code at the reset handler entry point. 
What I already did at an earlier project is to have the reset hanlder start the bootloader stored in ROM if a magic key is set in RAM. I would like to do something similar. After the bootloader successfully writes the user code into flash I just want to invalidate the magic Key and reboot into the normal user program.
I imagine running the bootloader is like having two different programs in the flash memory at different starting locations and just needing to decide which one to run. So far I do understand what I am doing but now I think I need to modify the linker script to privide the addresses of these entry points.
The default linker script provides the flash address called
'_sidata = __etext;' (I am using Coocox)
which is referenced in the assembler startup code.
How can I modify the linker script (as well as the startup code) so the code can load both programs (user code and bootloader)? Should I just use hardcoded addresses? What would the startup code look like?

Or is there a better way to do this? I did not find any good example of this.