cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX bug when use Memory management

luke gong
Associate II

MCU: STM32H743IIT6

When using Cubemx on Mac M1, enable "Apply Application Regions Settings to Linker Files", the generated .ld file error

lukegong_0-1722827489500.jpeg

/*
******************************************************************************
**

** File : LinkerScript.ld
**
** Author : STM32CubeMX
**
** Abstract : Linker script for STM32H743IITx series
** 2097152Kbytes FLASH and 0Kbytes RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : STMicroelectronics STM32
**
** Distribution: The file is distributed "as is," without any warranty
** of any kind.
**
*****************************************************************************
** @attention
**
** <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
**
** Redistribution and use in source and binary forms, with or without modification,
** are permitted provided that the following conditions are met:
** 1. Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** and/or other materials provided with the distribution.
** 3. Neither the name of STMicroelectronics nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*****************************************************************************
*/

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = ORIGIN() + LENGTH(); /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x8; /* required amount of heap */
_Min_Stack_Size = 0x8; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 131072K
RAM_AXI0 (rwx) : ORIGIN = 0x24000000, LENGTH = 524288K
RAM_D2 (rwx) : ORIGIN = 0x30000000, LENGTH = 294912K
RAM_D3 (rwx) : ORIGIN = 0x38000000, LENGTH = 65536K
ITCMRAM (rwx) : ORIGIN = 0x00000000, LENGTH = 65536K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2097152K
SDRAM (rwx) : ORIGIN = 0xc0000000, LENGTH = 33554432K
}

/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH

/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)

KEEP (*(.init))
KEEP (*(.fini))

. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH

/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH

.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH

.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH

/* used by the startup to initialize data */
_sidata = LOADADDR(.data);

/* Initialized data sections goes into RAM, load LMA copy after code */
.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 */
} > AT> FLASH

 
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)

. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >

/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >

 

/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}

.ARM.attributes 0 : { *(.ARM.attributes) }
}



6 REPLIES 6
Imen.D
ST Employee

Hello @luke gong 

Which CubeMx version used? Did you have this issue with latest release of CubeMx (v6.12.0)?

Could you please attach your ioc file, this will help our team to reproduce the issue.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Imen.D
ST Employee

Hi @luke gong ,

We are currently in the process of investigating the issue.

Could you kindly provide us with more information about the version of macOS and CubeMX that was used?

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

same on cubemx v6.12.1 when using a stm32f103c8t6. the line 

_estack = ORIGIN(RAM) + LENGTH(RAM);

is mistakenly generated as 

_estack = ORIGIN() + LENGTH();

in flash.ld

Hello, 

After checking, it seems that the issue is only observed when generating a CMake project, moreover when disabling the Code Generation Config in MMT, the .ld file is generated correctly.
Actually, the Cmake toolchain was added recently in CubeMX, but it currently does not support MMT.

The support of MMT with the Cmake project in STM32CubeMX is planned for the coming releases.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
derp
Associate

Well, just updated CubeMX (Windows) and ran into the same issue.

 

diff between STM32L432KCUx_FLASH.ld (generated after update, faulty)
and ACP14_STM32L432KCUx_FLASH.ld (the previous version of that file, working)

10c10
< **                256Kbytes FLASH and 80Kbytes RAM
---
> **                256Kbytes FLASH and 64Kbytes RAM
56c56
< _estack = ORIGIN(RAM) + LENGTH(RAM);    /* end of RAM */
---
> _estack = ORIGIN() + LENGTH();    /* end of RAM */
64c64
< RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 64K
---
> RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 48K
161c161
<   } >RAM AT> FLASH
---
>   } > AT> FLASH
178c178
<   } >RAM
---
>   } >
189c189
<   } >RAM
---
>   } >
201d200
<   .ARM.attributes 0 : { *(.ARM.attributes) }

 nothing changed in the cubeMX project, also tried to fall back to a previous firmware, no success
(STM32Cube FW_L4 V1.18.0 vs STM32Cube FW_L4 V1.18.1)

 

project type is Makefile.

 

Also just created a fresh project with defaults, same issue with the .ld file.

Downloading CubeMX 6.12.0 to see if I see a difference.

attached are the ld files of the same project, the one with ACP14 at the beginning is the working one, the other is the one generated with CubeMX 6.12.1 and faulty.

 

 

derp
Associate

update:

code and .ld file is generated correctly with 6.12.0 but not with 6.12.1 (for a makefile project)

Tested with the existing project* and a new one.

 

does not seem to relate to the firmware package version, even with 'STM32Cube FW_L4 V1.18.1' it works.
I did however not update any embedded software packages.

 

attached are default-peripheral projects for the NUCLEO-L432KC, filename states which cubemx version (and if its BAD or GOOD)

sticking with 6.12.0 for now.

 

* downgrading the .ioc file to load in an older version of CubeMX (older than 6.12.1)
change

MxCube.Version=6.12.1
MxDb.Version=DB.6.0.121

 to

MxCube.Version=6.12.0
MxDb.Version=DB.6.0.120