cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446 FMC SDRAM and linker script

YDann.7
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
YDann.7
Associate III

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.

View solution in original post

5 REPLIES 5

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
Associate III

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.

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
Up vote any posts that you find helpful, it shows what's working..

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
Associate III

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.