2025-10-11 5:41 AM
Hi
I am now working on porting an MDK example to CubeIDE on an F767-based customized board with 32MB SDRAM and an LCD interface.
At the moment, the build of the ported example in CubeIDE gives following erorr message:
The following is the original code of the example targeting on ARM compiler:
static __align(64) uint8_t mem1base[160*1024];
static __align(64) uint8_t mem2base[28912*1024] __attribute__((at(0XC01F4000)));
static __align(64) uint8_t mem3base[60*1024] __attribute__((at(0X20000000)));
static uint32_t mem1mapbase[160*1024/64];
static uint32_t mem2mapbase[28912*1024/64] __attribute__((at(0XC01F4000 + 28912*1024)));
static uint32_t mem3mapbase[60*1024/64] __attribute__((at(0X20000000 + 60*1024)));
Now after the porting, the code is changed to:
/* mem1 (internal RAM) (64 bytes alignment) */
__attribute__((section(".mem1base.mem1_base"))) static uint8_t mem1base[160 * 1024] = { 0 };
// mem2 (32MB external SDRAM)
// 64 bytes alignment, start address = 0XC01F4000
// the first 2MB is used by LTDC (1280*800*2)
__attribute__((section(".mem2base.mem2_base"))) static uint8_t mem2base[28912 * 1024] = { 0 };
// mem3 (CCMRAM, 64KB, used only by MCU)
// 64 bytes alignment, start address = 0X20000000
__attribute__((section(".mem3base.mem3_base"))) static uint8_t mem3base[60 * 1024] = { 0 };
__attribute__((section(".mem1mapbase.mem1map_base"))) static uint32_t mem1mapbase[160 * 1024 / 64] = { 0 };
__attribute__((section(".mem2mapbase.mem2map_base"))) static uint32_t mem2mapbase[28912 * 1024 / 64] = { 0 };
__attribute__((section(".mem3mapbase.mem3map_base"))) static uint32_t mem3mapbase[60 * 1024 / 64] = { 0 };
__attribute__((section(".ltdc_lcd_framebuf.lcd_framebuf"))) uint16_t ltdc_lcd_framebuf[1280][800];
I have no previous experiences on modifying a linker script, all I learned was from STM32CubeIDE User Guide, and the following are my modifications:
address calculations for those in the following script:
/* Memories definition */
/*
********************************************************
** Original Memories definition
MEMORY
{
RAM (xrw) : ORIGIN = 0X20000000, LENGTH = 512K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
}
********************************************************
*/
MEMORY
{
MEM3BASE (xrw) : ORIGIN = 0X20000000, LENGTH = 60K
MEM3MAP (xrw) : ORIGIN = 0x2000F000, LENGTH = 1K
MEM1BASE (xrw) : ORIGIN = 0x2000F400, LENGTH = 160K
MEM1MAP (xrw) : ORIGIN = 0x20037400, LENGTH = 3K
RAM (xrw) : ORIGIN = 0x20038000, LENGTH = 512K-224K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
LCD_BUF (xrw) : ORIGIN = 0XC0000000, LENGTH = 2000K
MEM2BASE (xrw) : ORIGIN = 0XC01F4000, LENGTH = 28912K
MEM2MAP (xrw) : ORIGIN = 0XC1E30000, LENGTH = 452K
}
/* Initialized data sections into "RAM" Ram type memory */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM
/* Place array mem1base into internal memory MEM1 region */
.mem1base :
{
. = ALIGN(64);
_smem1base = .; /* create a global symbol at data start */
*(.mem1base) /* .mem1base sections */
*(.mem1base*) /* .mem1base* sections */
. = ALIGN(64);
_emem1base = .; /* define a global symbol at data end */
} >MEM1BASE
/* Place array mem1mapbase into internal memory MEM1 region */
.mem1mapbase :
{
. = ALIGN(4);
_smem1mapbase = .; /* create a global symbol at data start */
*(.mem1mapbase) /* .mem1mapbase sections */
*(.mem1mapbase*) /* .mem1mapbase* sections */
. = ALIGN(4);
_emem1mapbase = .; /* define a global symbol at data end */
} >MEM1MAP
/* Place array mem2base into external SDRAM memory MEM2 region */
.mem2base :
{
. = ALIGN(64);
_smem2base = .; /* create a global symbol at data start */
*(.mem2base) /* .mem2base sections */
*(.mem2base*) /* .mem2base* sections */
. = ALIGN(64);
_emem2base = .; /* define a global symbol at data end */
} >MEM2BASE
/* Place array mem2mapbase into external SDRAM memory MEM2 region */
.mem2mapbase :
{
. = ALIGN(4);
_smem2mapbase = .; /* create a global symbol at data start */
*(.mem2mapbase) /* .mem2mapbase sections */
*(.mem2mapbase*) /* .mem2mapbase* sections */
. = ALIGN(4);
_emem2mapbase = .; /* define a global symbol at data end */
} >MEM2MAP
/* Place array ltdc_lcd_framebuf into external SDRAM memory LTDC_FRAME_BUF region */
.ltdc_lcd_framebuf :
{
. = ALIGN(4);
_sltdc_lcd_framebuf = .; /* create a global symbol at data start */
*(.ltdc_lcd_framebuf) /* .ltdc_lcd_framebuf sections */
*(.ltdc_lcd_framebuf*) /* .ltdc_lcd_framebuf* sections */
. = ALIGN(4);
_eltdc_lcd_framebuf = .; /* define a global symbol at data end */
} >LCD_BUF
/* Place array mem3base into CCMRAM memory MEM3 region */
.mem3base :
{
. = ALIGN(64);
_smem3base = .; /* create a global symbol at data start */
*(.mem3base) /* .mem3base sections */
*(.mem3base*) /* .mem3base* sections */
. = ALIGN(64);
_emem3base = .; /* define a global symbol at data end */
} >MEM3BASE
/* Place array mem3mapbase into CCMRAM memory MEM3 region */
.mem3mapbase :
{
. = ALIGN(4);
_smem3mapbase = .; /* create a global symbol at data start */
*(.mem3mapbase) /* .mem3mapbase sections */
*(.mem3mapbase*) /* .mem3mapbase* sections */
. = ALIGN(4);
_emem3mapbase = .; /* define a global symbol at data end */
} >MEM3MAP
I must have done something wrong in this script, so please point them out to me, it would be highly appreciated!
Many thanks in advance!
Chao
2025-10-11 9:32 AM
Look in the map file to see what is taking up so much space.
Probably the mem2mapbase section needs to be marked as NOLOAD.