Skip to main content
YDann.7
Associate III
May 21, 2019
Solved

STM32F446 FMC SDRAM and linker script

  • May 21, 2019
  • 5 replies
  • 1640 views

Dear,

For the first time, i use an external SDRAM with the FMC peripheral of the STM32F446.

I succeeded to describe a in the linker script to place specific data in this section.

BUT this section is present in the output file (.hex) when I build my code. Because it's a section with just uninitialized data, this section must not be in the output file.

Maybe I did something wrong ???

In linker script :

XRAM1 (xrw) : ORIGIN = 0xC0000000, LENGTH = 1920K
 
/* External RAM section */
.xram1 :
{
 *(.xram1*);
} >XRAM1

In header Cpp file :

class SDRAM
{
public:
 ....
 __attribute__((section(".xram2"))) static u8 sData[10][10][10][10];
 ....
};

  I use Atollic as IDE with gcc.

This topic has been closed for replies.
Best answer by YDann.7

Dear,

Problem solved.

When you precise a section where datas are located, gcc considere this datas as initialized datas. And this datas are in output file.

I use the "NOLOAD" option for section as suggest waclawek.jan.

5 replies

waclawek.jan
Super User
May 21, 2019

Assuming you are using the GNU linker, ld, use NOLOAD as output section type.

https://sourceware.org/binutils/docs/ld/Output-Section-Type.html#Output-Section-Type

You could also strip that output section when generating the hex file using objcopy, using -R/--remove-section.

JW

YDann.7
YDann.7Author
Associate III
May 21, 2019

Dear,

Thanks for your answer.

Yes, i use GNU linker (*.ld file).

If I understand, the both solution produce the same effect. The data located in the external SDRAM will have a random value at startup because this section will be ignore/unknow at the startup BUT the memory space will be available at the runtime. Is it true ?

And why I have this problem ? Because I have declare the variable as static membre of the class ?

Regards.

Tesla DeLorean
Guru
May 21, 2019

RAM content needs to be stored in FLASH, and routines in startup.s will need to copy the content into RAM.

C related stuff would be "statics" and C++ would be constructors.

The SDRAM pins, peripheral and chip will need to be initialized before you attempt to use them. This would typically be code in SystemInit() which would initialize clocks, pins, peripherals, external buses, etc.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
YDann.7
YDann.7Author
Associate III
May 21, 2019

RAM content needs to be stored in FLASH, and routines in startup.s will need to copy the content into RAM.

I am agree with that but only for the initialized variables (data located in .data section).

The SDRAM pins, peripheral and chip will need to be initialized before you attempt to use them. This would typically be code in SystemInit() which would initialize clocks, pins, peripherals, external buses, etc.

It's for that. My code initializes correctly the chip in SystemInit() to use the FMC peripheral.

But the static member in Cpp class have not a specific initialization so need to be in .bss section if I don't specify the section is which it is located (and not present in .hex file).

In my case, the .hex file contains the entire space of this section with data 0 like value.

YDann.7
YDann.7AuthorBest answer
Associate III
May 22, 2019

Dear,

Problem solved.

When you precise a section where datas are located, gcc considere this datas as initialized datas. And this datas are in output file.

I use the "NOLOAD" option for section as suggest waclawek.jan.