STM32F446 FMC SDRAM and linker script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-21 8:06 AM
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.
Solved! Go to Solution.
- Labels:
-
FMC-FSMC
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-22 8:02 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-21 9:07 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-21 9:52 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-21 11:12 AM
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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-21 1:46 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-22 8:02 AM
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.
