AnsweredAssumed Answered

Declaring variables in External SRAM

Question asked by Ancaritha on Sep 23, 2016
Latest reply on Sep 23, 2016 by Ancaritha
Hi everyone!  I'm having some difficulty getting variables to be declared in external SRAM.  I'm using a STM32L4.  If I do address casting like the FMC example project for the eval board in the library code I can access the SRAM, but I can't seem to declare a variable to be always there.

Here are the changes I've made to the default STM32L476G linker file:

/* Specify the memory areas */
FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 1024K
RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 96K
SRAM (xrw) : ORIGIN = 0x60000000, LENGTH = 128K

And at the end:

/* Add section for external RAM */
  .bssext :
    _sbssext = .;         /* define a global symbol at bssext start */
    __bssext_start__ = _sbssext;

     . = ALIGN(4);
     _ebssext = .;         /* define a global symbol at bssext end */
    __bssext_end__ = _ebssext;

  /* Remove information from the standard libraries */
 /* Unchanged, but included to show where it is in the linker file */
    libc.a ( * )
    libm.a ( * )
    libgcc.a ( * )

At the top of one of my files I'm declaring a variable as such:
__attribute__((section(".bssext"))) uint8_t pExtMemoryTest[32];

This should be putting it into the .bssext section, which should be in SRAM, but the map file says it's still in regular ram.

                0x20002368      0x200 Debug/CdcRxForwardTask.o
 .bssext        0x20002568       0x20 Debug/DpmBootTask.o
                0x20002568                pExtMemoryTest

                0x20002588        0x4 Debug/DpmHwInit.o
                0x20002588                _ZN6HwInit14m_nResetReasonE

It's right in the middle of the .bss section and is clearly in internal RAM.

What am I missing?  Any help would be greatly appreciated, thanks!