Need help in Keil 5 locating code for RAM execution

I am using an STM32F439VGTx, which has
flash starting at 0x08000000, length 0x00100000
and CCM RAM starting at 0x10000000, length 0x00010000
and normal RAM starting at 0x20000000, length 0x00030000
I want some of my code and constant data to be in flash,
and some code to be executed out of RAM.  How can I
tell the compiler to compile some functions or modules
to execute in RAM, but place the compiled code in flash
so I can copy it to RAM for execution?  For example,
I might have a function called RamFunc(), which I would like
placed in RAM at some address, (say 0x20000800 or maybe 0x100000800),
but I need the image of it in flash at a known address, say 0x08001000,
and a known length so I can copy it to RAM for execution.

I have tried many variations of settings in a .sct file, and also tried
various versions using a Debug_RAM.ini file, as in the CMSIS-RTOS Blinky (MCBSTM32E)
example.  Nothing has worked for me.

Any help would be greatly appreciated.

Parents
  • I suspect you're trying too hard.

    I'm pretty sure you don't have to do the copying from flash to RAM yourself.  The linker and startup code should be quite capable of doing that for you, once you've set up the specific code section and linker script correctly.  As a benefit of that, you also won't have to insist on fixed addresses, either, because the start-up machinery gets all the information it needs for that job from the linker, already.  All you have to do is let the tools do their job.

Reply
  • I suspect you're trying too hard.

    I'm pretty sure you don't have to do the copying from flash to RAM yourself.  The linker and startup code should be quite capable of doing that for you, once you've set up the specific code section and linker script correctly.  As a benefit of that, you also won't have to insist on fixed addresses, either, because the start-up machinery gets all the information it needs for that job from the linker, already.  All you have to do is let the tools do their job.

Children