Skip to main content
Associate
June 16, 2026
Solved

STM32CubeMX generates incorrect linker script for BKPRAM (backup RAM) via Memory Management Tool

  • June 16, 2026
  • 5 replies
  • 107 views

STM32CubeMX generates incorrect linker script for BKPRAM (Backup RAM) via Memory Management Tool

Environment

  • STM32CubeMX: v6.17.0, see "Memory Management" (Tools > Memory Management)
  • MCU: STM32H523RETx
  • Toolchain: STM32CubeIDE - GNU Tools for STM32 (14.3.rel1)

Applied Memory Setup (screenshot):

STM32CubeMX generates 3 linker scripts (STM32H523RETX_FLASH.ldSTM32H523RETX_FLASH_MMT_TEMPLATE.ldSTM32H523RETX_RAM.ld). The STM32H523RETX_FLASH_MMT_TEMPLATE.ld is used in the generated STM32CubeIDE project output.

 

Issue 1: BKPRAM memory region has incorrect x (execute) permission

Generated linker script contains:

BKPRAM (xrw) : ORIGIN = 0x40036400, LENGTH = 2K

The x (executable) flag is incorrect. BKPSRAM is a data-only backup memory — it is not executable. According to RM0481 sec. 2.3, BKPSRAM is accessible only via the system bus (S-AHB), not the code bus (C-AHB). Marking it executable is misleading and may cause incorrect MPU configuration.

Expected:

BKPRAM (rw) : ORIGIN = 0x40036400, LENGTH = 2K

Issue 2: .BKPRAM section is missing the (NOLOAD) keyword

Generated linker script contains:

.BKPRAM :
{
. = ALIGN(4);
KEEP (*(.BKPRAM))
. = ALIGN(4);
} >BKPRAM

The (NOLOAD) keyword is missing. Without it, the GCC linker creates a load memory address (LMA) in flash and the startup code attempts to copy BKPRAM contents from flash to address 0x40036400 at boot. This fails because:

  1. BKPSRAM at 0x40036400 is a peripheral-bus-mapped memory — it cannot be accessed via the C-AHB code bus used during the startup copy
  2. The DBP bit (PWR_DBPCR) and BKPRAM clock (RCC) are not yet enabled at the time of the startup copy
  3. BKPSRAM is intended to retain data across resets — overwriting it at startup defeats its purpose

Expected:

.BKPRAM (NOLOAD) :
{
. = ALIGN(4);
KEEP (*(.BKPRAM))
. = ALIGN(4);
} >BKPRAM

NOLOAD is the correct GCC linker keyword to mark a section as not initialized from flash.

 

Impact

Both issues affect the generated file STM32H523RETX_FLASH_MMT_TEMPLATE.ld. Using the generated linker script without manual correction results in a HardFault or a failed debug session when BKPRAM variables are declared with __attribute__((section(".BKPRAM"))).

Could you please advise whether there is a way to configure STM32CubeMX to generate the correct linker script content? If not, please report these these two issues as a bug.

 

Thank you in advance.

Regards, Vit

 

Best answer by Mahmoud Ben Romdhane

Hello ​@vit.triska 

Let me thank you for bringing this behavior to our attention.

An internal ticket has been reported to the dedicated team (Ticket Number: CDM0063847).

Thanks.

Mahmoud

 

5 replies

ST Technical Moderator
June 17, 2026

Hello ​@vit.triska 

Let me thank you for posting and welcome to the ST Community.

For more investigation, I recommend that you provide your Ioc.File.

Thanks.

Mahmoud

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Associate
June 17, 2026

Hello, sure, the “fw.ioc” file attached. Thanks, Vit

ST Technical Moderator
June 26, 2026

Hello ​@vit.triska 

Let me thank you for bringing this behavior to our attention.

An internal ticket has been reported to the dedicated team (Ticket Number: CDM0063847).

Thanks.

Mahmoud

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Associate
June 26, 2026

Hello,


Do you have any estimate when this issue might be fixed?

Any tentative timeline when this issue will be resolved in STM32CubeMX?

Can I follow your “Ticket Number CDM0063847”, or be informed about progress?

 

Regards,

Vit

 

ST Technical Moderator
June 26, 2026

Hello ​@vit.triska 

I'll let you know as soon as the problem is resolved.

Thanks.

Mahmoud

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.