cancel
Showing results for 
Search instead for 
Did you mean: 

Linker file STM32F429

m_
Associate II
Posted on May 21, 2014 at 13:48

Hello

We have made a custom board which uses a STM32F429II. On that board we also have a SDRAM memory chip of 512Kbit that is connected to the STM32 with the FMC peripheral.

We confirmed that the memory chip is working correctly as we can write and read to the chip using functions like:

uint32_t SDRAM_Read32b(uint32_t adr)

{

  uint32_t ret_wert=0;

  ret_wert = *(__IO uint32_t*)(SDRAM_START_ADR + adr);

  return(ret_wert);

}

Which uses pointers to point to the SDRAM adress. 

In previous projects with stm32 wich used SRAM we could create a variable with a certain attribute:

__attribute__((section(''.sram_data''))) char buffer[10000];

and then use this variable as if it is normal RAM memory.

This requires to change the linker script which the compiler uses. But when we do the same with the new STM32F429 chip the data is not stored at all.

We are also not sure how to correctly adapt the linker script. Is there someone who also used this for embedded SDRAM or who can give us a correct example of a linker script adapted for external RAM?
4 REPLIES 4
Posted on May 21, 2014 at 14:10

No, you'd need to initialize the SDRAM (512Kbit? What part?), ie GPIO, FMC, SDRAM before you could use it. This would need to get done early in the Reset_Handler, or within the SystemInit() code before you attempt to run the C runtime start up code.

The STM32F429I-DISCO has examples for SDRAM, and I've posted startup code before
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
m_
Associate II
Posted on May 21, 2014 at 14:25

The part used is the: AS4C32M16SA-7TCN 

We already made a Init function for the SDRAM which includes: gpio, clocks, fmc etc etc...

We also tested the SDRAM with functions to single write data.

But we want to use the data in the SDRAM as normal ram so that the FMC module does all the other work. Therefore the linker script needs to be adjusted I think?

Could you give me a link or description to your post about the linker?

 

Posted on May 21, 2014 at 15:29

Ok, so a 512 Mbit (64MByte) part, not 512 Kbit, so the size/geometry settings will be a bit different from the STM32F429I-DISCO and STM324x9I-EVAL.

/*
Linker script for STM32F429I-DISCOVERY - STM32F429ZI - sourcer32@gmail.com
*/
/* include the common STM32F429 sub-script */
INCLUDE ''STM32F429_COMMON.ld''
/* Memory Spaces Definitions */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2M
CCM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
SDRAM (rw) : ORIGIN = 0xD0000000, LENGTH = 8M
}
/* highest address of the user mode stack */
_estack = 0x20030000;
/* Sections Definitions */
SECTIONS
{
/* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */
.flashtext :
{
. = ALIGN(4);
*(.flashtext) /* Startup code */
. = ALIGN(4);
} >FLASH
/* the program code is stored in the .text section, which goes to Flash */
.text :
{
. = ALIGN(4);
*(.text) /* remaining code */
*(.text.*) /* remaining code */
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4);
_etext = .;
/* This is used by the startup in order to initialize the .data secion */
_sidata = _etext;
} >FLASH
/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
It is one task of the startup to copy the initial values from FLASH to RAM. */
.data : AT ( _sidata )
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_sdata = . ;
*(.data)
*(.data.*)
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_edata = . ;
} >RAM
/* This is the uninitialized data section */
.bss :
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .;
*(.bss)
*(.bss.*)
*(COMMON)
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_ebss = . ;
} >RAM
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
/* This is the user stack section
This is just to check that there is enough RAM left for the User mode stack
It should generate an error if it's full.
*/
._usrstack :
{
. = ALIGN(4);
_susrstack = . ;
. = . + _Minimum_Stack_Size ;
. = ALIGN(4);
_eusrstack = . ;
} >RAM
__exidx_start = .;
__exidx_end = .;
.ccm (NOLOAD) :
{
. = ALIGN(4);
*(.ccm)
*(.ccm.*)
. = ALIGN(4);
} >CCM
.sdram (NOLOAD) :
{
. = ALIGN(4);
*(.sdram)
*(.sdram.*)
. = ALIGN(4);
} >SDRAM
/* after that it's only debugging information. */
/* remove the debugging information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
m_
Associate II
Posted on May 21, 2014 at 17:54

Thank you very much for the example!