2015-05-21 03:39 AM
Hi,
I want to execute my code from SRAM of STM32F100. I basically want to copy a program from flash to SRAM and execute the program from SRAMPlease help me understand how this can be addressed.Regards Tejas #flash #stm32f100 #sram2015-05-21 05:30 AM
What's the stumbling block here? Building the code for a different address, or the copying part?
Assuming you have a part with 64KB of RAM, I'd split it in two halves, and have code in the ResetHandler to copy the body in RAM and then forking to it. Have the linker build the Code portion for 0x20000000[0x8000] and the Data portion for 0x20008000[0x8000]. To make the flashing easier I'd probably need to rebase the .HEX file so the ST-LINK Utilities could deliver it, or just convert it to a .BIN and tell the tools explicitly where to write it.2015-05-27 12:24 AM
Actually, I've not started coding on this section. I wanted to start with understanding on how to copy binary from flash to RAM and execute files from RAM.
My main aim is to copy the 'In application program' to RAM and execute the program from RAM so that I have a option to even re write entire flash.2015-05-27 07:16 AM
If you want to run the same code (i.e. the same binary image) loaded both at 0x2000 and 0x0800, you will need to generate ''position-independant code'', there are usually compiler options for that.
Or, what I would do is tweak the linker script to make it use a VMA of 0 and a LMA in flash (0x0800). In normal operation (run from flash), set the core to map the flash area @ 0. When you want to run from ram, you copy the whole image to RAM, change the memory mapping so RAM is mapped @ 0, and just keep going. ( Make sure you have enough RAM for both your stack and your code !)