Skip to main content
Explorer
July 10, 2025
Solved

STM32U5: Bootloader in Internal Flash can't run Application in External OctoSPI NOR Flash

  • July 10, 2025
  • 1 reply
  • 577 views

Hi All,

I’m working on a project with the STM32U5G9ZJT6, where I’ve implemented a bootloader in internal flash at 0x08000000. The application is stored in external OctoSPI NOR flash (MX66LM1G45G), which is memory-mapped to address 0xA0000000 using Octal STR mode.

I'm flashing the application binary into external flash using an external loader (.stldr) via STM32CubeIDE.

Although the application is successfully stored in external flash, when I try to execute it via memory-mapped mode, it fails (shows “Target Failed” or halts). I’m not sure whether it’s due to memory mapping, stack configuration, MPU, or something else.

Could someone guide me on the correct procedure or help me troubleshoot this issue?

 

What I’ve Done So Far:
Bootloader:

Configured OSPI (HSPI1 / OCTOSPI2) to enable memory-mapped mode using MX66LM1G45G_EnableSTRMemoryMappedMode().

Verified that data can be read from 0xA0000000.

Read the initial MSP and Reset_Handler from external flash:


uint32_t app_msp = *(uint32_t*)0xA0000000;
uint32_t app_reset = *(uint32_t*)(0xA0000000 + 4);
Jumped to the application using:

__disable_irq();
HAL_RCC_DeInit();
HAL_DeInit();
SysTick->CTRL = 0;
__set_MSP(app_msp);
SCB->VTOR = 0xA0000000;
((void (*)(void))app_reset)();


Memory Mapping:

Bootloader stack: 0x20000000 (top of SRAM2)

Application stack: 0x20080000 (top of SRAM1)

Linker scripts split RAM regions accordingly

Application binary is placed at 0xA0000000 using a custom .ld file and flashed using STM32CubeProgrammer with .stldr loader

Problem / Clarification Needed:
After jumping to the application, am getting below issue.

sravani_0-1752126056297.png

 

I want to confirm:

Is the SCB->VTOR method enough for XIP from external flash?

Are there MPU or cache settings I need to change before jumping?

Should I manually clean/disable any cache (ICACHE, DCACHE) before the jump?

Any special constraints for enabling OctoSPI STR mode with XIP on STM32U5?

 

Please provide any reference links.

    This topic has been closed for replies.
    Best answer by Saket_Om

    Hello @sravani 

    Please refer to example below: 

    STM32CubeU5/Projects/B-U585I-IOT02A/Examples/OCTOSPI/OSPI_PSRAM_ExecuteInPlace at main · STMicroelectronics/STM32CubeU5 · GitHub

    This example describes how to execute a part of the code from a OSPI PSRAM memory.

    1 reply

    Technical Moderator
    July 11, 2025

    Hello @sravani 

    Please refer to the example QSPI_ExecuteInPlace and get inspired from it. 

    sravaniAuthor
    Explorer
    July 12, 2025

    Thank you for your response, Saket_Om.

    Could you kindly share an example for the STM32U5 series?

     

    Saket_OmAnswer
    Technical Moderator
    July 14, 2025

    Hello @sravani 

    Please refer to example below: 

    STM32CubeU5/Projects/B-U585I-IOT02A/Examples/OCTOSPI/OSPI_PSRAM_ExecuteInPlace at main · STMicroelectronics/STM32CubeU5 · GitHub

    This example describes how to execute a part of the code from a OSPI PSRAM memory.