Stack Memory Location is not writable

Sysprogs forums Forums VisualGDB Stack Memory Location is not writable

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8843
    Rumchiller
    Participant

    Hello,

    I have a SDRAM linked to my STM32F4. So I edited the linkerscript and startupfile:

     

    /* Generated by LinkerScriptGenerator [http://visualgdb.com/tools/LinkerScriptGenerator]
    * Target: STM32F429IG
    * The file is provided under the BSD license.
    */

    ENTRY(Reset_Handler)

    MEMORY
    {
    FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 1M
    SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 192K
    CCM (RWX) : ORIGIN = 0x10000000, LENGTH = 64K
    BACKUP_SRAM (RWX) : ORIGIN = 0x40024000, LENGTH = 4K
    SDRAM (RWX) : ORIGIN = 0xD0000000, LENGTH = 8M
    }

    _estack = 0x20030000;

    SECTIONS
    {
    .isr_vector :
    {
    . = ALIGN(4);
    KEEP(*(.isr_vector))
    . = ALIGN(4);
    } > FLASH

    .text :
    {
    . = ALIGN(4);
    _stext = .;

    *(.text)
    *(.text*)
    *(.rodata)
    *(.rodata*)
    *(.glue_7)
    *(.glue_7t)
    KEEP(*(.init))
    KEEP(*(.fini))
    . = ALIGN(4);
    _etext = .;

    } > FLASH

    .ARM.extab :
    {
    . = ALIGN(4);
    *(.ARM.extab)
    *(.gnu.linkonce.armextab.*)
    . = ALIGN(4);
    } > FLASH

    .exidx :
    {
    . = ALIGN(4);
    PROVIDE(__exidx_start = .);
    *(.ARM.exidx*)
    . = ALIGN(4);
    PROVIDE(__exidx_end = .);
    } > FLASH

    .ARM.attributes :
    {
    *(.ARM.attributes)
    } > FLASH

    .preinit_array :
    {
    PROVIDE(__preinit_array_start = .);
    KEEP(*(.preinit_array*))
    PROVIDE(__preinit_array_end = .);
    } > FLASH

    .init_array :
    {
    PROVIDE(__init_array_start = .);
    KEEP(*(SORT(.init_array.*)))
    KEEP(*(.init_array*))
    PROVIDE(__init_array_end = .);
    } > FLASH

    .fini_array :
    {
    PROVIDE(__fini_array_start = .);
    KEEP(*(.fini_array*))
    KEEP(*(SORT(.fini_array.*)))
    PROVIDE(__fini_array_end = .);
    } > FLASH

    . = ALIGN(4);
    _sidata = .;
    .data : AT(_sidata)
    {
    . = ALIGN(4);
    _sdata = .;

    PROVIDE(__data_start__ = _sdata);
    *(.data)
    *(.data*)
    . = ALIGN(4);
    _edata = .;

    PROVIDE(__data_end__ = _edata);
    } > SRAM

    .bss :
    {
    . = ALIGN(4);
    _sbss = .;

    PROVIDE(__bss_start__ = _sbss);
    *(.bss)
    *(.bss*)
    *(COMMON)
    . = ALIGN(4);
    _ebss = .;

    PROVIDE(__bss_end__ = _ebss);
    } > SRAM

    . = ALIGN(4);
    _sisdraminit = .;
    .sdraminit : AT( _sisdraminit )
    {
    . = ALIGN(4);
    _ssdraminit = .;

    *(.sdraminit)
    *(.sdraminit*)
    . = ALIGN(4);
    _esdraminit = .;
    } > SDRAM

    .sdram (NOLOAD) :
    {
    . = ALIGN(4);
    *(.sdram)
    *(.sdram.*)
    . = ALIGN(4);
    } > SDRAM

    PROVIDE(end = .);

    }

     

    extern void *_sidata, *_sdata, *_edata;
    extern void *_sbss, *_ebss;
    extern void *_sisdraminit, *_ssdraminit, *_esdraminit;

    void __attribute__((naked, noreturn)) Reset_Handler()
    {
    //Normally the CPU should will setup the based on the value from the first entry in the vector table.
    //If you encounter problems with accessing stack variables during initialization, ensure the line below is enabled.
    #ifdef sram_layout
    asm(“ldr sp, =_estack”);
    #endif

    void **pSource, **pDest;
    for (pSource = &_sidata, pDest = &_sdata; pDest != &_edata; pSource++, pDest++)
    *pDest = *pSource;

    for (pDest = &_sbss; pDest != &_ebss; pDest++)
    *pDest = 0;

    SystemInit();
    FmcInit();
    __libc_init_array();

    pSource = &_sisdraminit;
    for (pDest = &_ssdraminit; pDest < &_esdraminit;)
    *(pDest++) = *(pSource++);

    (void)main();
    for (;;);
    }

    Then, with:

    // SDRAM
    #define DEF_IN_SDRAM __attribute__((section(".sdram")))
    #define INIT_IN_SDRAM __attribute__((section(".sdraminit")))

    i can initialize an array:

    static INIT_IN_SDRAM char OBJECTS_BUFFER1[5] = { 1,2,3,4,5 };
    

     

    The problem is, when I initialize an array 1MB of size, i get an error, although, the array is created:

    The memory location used for the stack (0x2002fffc) is not writeable. Please check the selected device type and the linker script. You can disable automatic stack checking via VisualGDB Project Properties.

     

     

    And: Is there a help for this forum in terms of formating :>

    • This topic was modified 7 years, 8 months ago by Rumchiller.
    • This topic was modified 7 years, 8 months ago by Rumchiller.
    #8856
    support
    Keymaster

    Hi,

    We would recommend using the External Memories feature of VisualGDB 5.1 for that (required Custom edition or higher). It will manage the linker scripts for you automatically and should avoid such problems.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.