How Can I define a SDRAM usage in the Script Linker.
Hello, everyone:
I just migrate my development job from MDK to STM32CubeIDE. But I've got a little problem, details as follows:
1.environment
STM32H750 + SDRAM(FMC), with bootloader in the AXI flash,but app was copied from spiFlash to AXI SRAM by the bootloader when system starts.
2.problem
when I DO my job on the MDK, i can define an huge array in the SDRAM using the statement like this:
unsigned char MemoryEx_Pool[MEMORY_EX_MAX_SIZE] __attribute__((at(SDRAM_BANK_1_ADDR)));where SDRAM_BANK_1_ADDR is defined as the start address of FMC 0xC0000000. Then nothing left to do, the compiler tools can deal with this automatically well. But on STM32CubeIde, it seems not that easy to get this work, I made some changes while migrating from MDK Project:
1). I changed my statement in the source code to define this array in the sdramas follows:
__attribute__((section(".sdram"))) unsigned char MemoryEx_Pool[MEMORY_EX_MAX_SIZE];here i intend to put this huge uninitialized array into section 'sdram' defined in the linker script later.
2). i chaged Memory definition a little bit in the linker script:
/* Memories definition */
MEMORY
{
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
DTCMRAM (rwxa) : ORIGIN = 0x20000000, LENGTH = 128K
IMAGE (rwx) : ORIGIN = 0x24000000, LENGTH = 350K
RAM_D1 (rwx) : ORIGIN = 0x24057800, LENGTH = 162K
ITCMRAM (rwx) : ORIGIN = 0x00000000, LENGTH = 64K
RAM_D3 (rwx) : ORIGIN = 0x38000000, LENGTH = 64K
RAM_D2 (rwx) : ORIGIN = 0x30000000, LENGTH = 288K
SDRAM (rwxa) : ORIGIN = 0xC0000000, LENGTH = 16384K
}here I split AXI SRAM into 2 parts, IMAGE(350k) for the app program image and RAM_D1(162K) for data use. And I add SDRAM definition here for use.
3).in the SECTION area of linker script , I put sdram input section to the SDRAM as follows:
.sdram_section :
{
. = ALIGN(4);
__SDARAM_START__ = .;
*(.sdram)
*(.sdram*)
. = ALIGN(4);
__SDRAM_END__ = .;
} >SDRAMhere I intend to put this huge uninitialized array (MemoryEx_Pool) defined in the soucre file to SDRAM.
THE PROBLEM IS : I got a huge .bin (about 2.2G ) after i comile and link the project while the .elf is about 13M. I inspect the build information as follows:
10:57:39 **** Incremental Build of configuration Debug for project CP300_BiSun_New ****
make -j6 all
arm-none-eabi-size CP300_BiSun_New.elf
text data bss dec hex filename
260020 13617084 126936 14004040 d5af48 CP300_BiSun_New.elf
Finished building: default.size.stdoutthe most huge part is data. it seems that the huge uninitialized array was taken into the data area and copied into the program image, but from what i understand ,it should be put into the bss.
so i want to ask:
1.where linker put my self-defined section to? for example i defined a sdram_section output section in the linker script,but i didn't see it in the build output information.
2.why my uninitialized huge array was put to the data section, from what i understand ,this data section is for the initialized data use.
3.why my .bin is so huge, how can i avoid this? how should i modify linker script if i want to use this sdram , for example, define an variable or array in it?
i really have no idea , i hope someone can help me out,relly appreciate!:grinning_face: