cancel
Showing results for 
Search instead for 
Did you mean: 

Running Code from SRAM

eduardo2
Associate II
Posted on September 02, 2014 at 23:13

Hi:

I am using STM3221G-EVAL board. The board has a couple of switches to select the Boot source.

Boot related jumpers

BOOT 0                 BOOT 1                 Boot source

    0                          1 or 0                      STM3221G-EVAL boots from

User Flash

(Default setting)

    1                          1                              STM3221G-EVAL boots from

Embedded SRAM

    1                          0                              STM3221G-EVAL boots from

System Memory

I would like to place the code in SRAM instead of User Flash. I am using the Demonstration Builder example firmware provided by ST and using IAR tool chain.

I have been changing parameters on the Linker and in some of the firmware header files, to avoid the errors, but the firmware doesn't work.

What are the normal guidelines to do this?

Thanks,

#run-code-from-sram
5 REPLIES 5
Posted on September 03, 2014 at 01:15

In Keil you use a debugger initialization script, to set up the hardware, and external buses as required, and load the firmware directly into RAM. This replaces the usual flash algorithm that downloads to flash. You also obviously have to build your code to reside in SRAM at 0x20000000, and move and shrink the usual RAM allocation depending on how large the code is.

ie IROM at 0x20000000 [0x10000]

  IRAM at 0x20010000 [0x10000]

IAR likely has similar debug and linker scripting (.icf), review your manuals and support materials.

The vector table (SCB->VTOR) is typically reconfigured in system-stm32f2xx.c
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
eduardo2
Associate II
Posted on September 03, 2014 at 20:04

I think the problem is the fact that the Demonstration firmware is too big to fit in the internal SRAM. I just try another code (much smaller) and ran it fine out of the internal SRAM.

However, the STM3221G-EVAL board has a 16 Mbit SRAM connected to FSMC bus of the STM32F217IGH6.

Is there anyway to put the code in the external SRAM chip and run it from there?

Thanks,

Posted on September 03, 2014 at 21:15

Like I said, in Keil you have this debugger script thing, in it you enumerate all the pokes (addresses, values) that you would normally do in ExternalMemInit() (or whatever) to walk the processor through the initialization of your clocks, pins and external memory bus interface. THEN the debugger can load your code into that memory.

I'm pretty sure IAR has a near identical scheme, I would perhaps look for examples of ARM9 boards, or others within the install, that primarily have external memory, say an ATMEL AT91SAM9260, and have a ''Run from SDRAM'' build target.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 29, 2017 at 06:56

I have also same problem and question. 

I would like to place the code in

SRAM

instead of User Flash. Did you resolve this problem? 
Posted on December 29, 2017 at 17:34

Both IROM and IRAM would need to be set to non-overlapping RAM addresses for the Linker to build a suitably based image.

On the F1 you'd need a small hack at the end of the vector table, as illustrated in the GNU/GCC start up file examples.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..