cancel
Showing results for 
Search instead for 
Did you mean: 

Section for external SDRAM STM32F746 GCC

43102399
Associate II
Posted on September 27, 2016 at 15:17

Hey guys,

I have a problem with defining a section for the external SDRAM on the STM32F746-Disco. I red many posts in different forums but I didn't find the way to a working code.

I initialized the SDRAM in the SystemInit() and it's working because I can use it in the main() function without additional initialisation. Afterwords I took the linker script and added a memory entry like followed:

MEMORY

{

FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K

RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K

SDRAM (xrw) : ORIGIN = 0xC0000000, LENGTH = 8M

}

and a section entry like this:

...

.sdram_data (NOLOAD) :

{

. = ALIGN(8);

_sdram_data_begin = .;

*(.sdram_data)

*(.sdram_data*)

. = ALIGN(8);

_sdram_data_end = .;

} >SDRAM

...

When I now declare a variable in the main file

const char picture1

http://www.openstm32.org/480%2a272%2a3

]__attribute__((section(''.sdram_data'')));

and want to fill it afterwards with information

picture1[] = {

0x00, 0xFF, 0xFF;

0x00, 0xFF, 0xFF;

0x00, 0xFF, 0xFF;

...

};

I get the error:

../src/main.c:53:1: warning: data definition has no type or storage class

picture1[] = {

^

../src/main.c:53:1: warning: type defaults to 'int' in declaration of 'picture1'

http://www.openstm32.org/-Wimplicit-int

../src/main.c:53:1: error: conflicting types for 'picture1'

../src/main.c:52:12: note: previous declaration of 'picture1' was here

const char picture1

http://www.openstm32.org/480%2a272%2a3

__attribute__((section(''.sdram_data'')));

When I declare the variable as followed I don't get an error but it's also not working.

__attribute__((section(''.sdram_data'')))

const char picture1[] =

{

0x00, 0xFF, 0xFF;

0x00, 0xFF, 0xFF;

0x00, 0xFF, 0xFF;

...

};

I hope anybody of you can help me.

#sdram #gcc-linker-ccm #memory-sections
2 REPLIES 2
Posted on September 27, 2016 at 17:38

NOLOAD or NOINIT type section aren't initialized, no data is backed behind them.

The data would need to be copied from FLASH during the start up code, and the SDRAM would need to be initialized, functionally, before the copy could be done. The linker script would need a ''>SDRAM AT> FLASH'' and you'd need to scope the beginning and end of that space to facilitate the copy, whose code you'd want to add.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
43102399
Associate II
Posted on September 28, 2016 at 13:53

Thanks clive for your answer...

I removed the ''NOLOAD'', added ''>SDRAM AT> FLASH'' and tried a lot other things. It's not working and I don't have any idea why not. Only I want store a picture in the external SDRAM which is too big for the flash.

Also I am confused because a normal declaration of a local variable as an array throws me an error.

uint32_t numbers[5] = {1, 2, 3, 4, 5};

is working fine, but when I declare like this

uint32_t numbers[5];

numbers = {1, 2, 3, 4, 5};

the compiler says me

../src/main.c:105:12: error: expected expression before '{' token

numbers = {1, 2, 3, 4, 5};

At the moment my section looks like that:

  .sdram_data :

  {

      . = ALIGN(4);

      __sdram_data_start__ = .;

      *(.sdram_data)

      *(.sdram_data*)

      . = ALIGN(4);

      __sdram_data_end__ = .;

  } >SDRAM AT>FLASH