We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am writing a bootloader for a STM32L controller. So far I have been using the Keil start up files, but now I need to tweak the load addresses and other stuff. I have written a custom scatter file, and my variables are copied from flash to ram as it is supposed, but I don't understand why? I can't find any code doing this in the startup files!
Is the embedded bootloader doing this work? How?
Just before main() is called, the startup file calls a helper function that prepares the runtime library. And then you also gets your initialized variables copied (and optionally decompressed) from flash, and get the uninitialized variables zeroed.
Without looking at startup files for your STM processor, you probably have a call to a function __main - note two underscores in front - at the end of the startup file. That is not your main() from your C code.
Thanks Per, you are right!
Do you know which symbols control the relocation (to- and from addreses, number of bytes, etc)?