This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Where are the variables copied from flash to ram?

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?

Parents
  • 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.

Reply
  • 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.

Children