cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U375 external loader issue with global variable initialization

AnnStett
Visitor

Hello,

I need to develop an external memory loader for a custom board with the STM32U375 and Macronix MX25U6432F NOR-Flash as external memory. The interface is via OCTOSPI1.

I have already tested the interface functions to access the external memory and everything is working fine when used within a "normal" application running in the STM32U3 internal flash.

As I am using the STM32CubeIDE, I created the code for the external memory loader based on the templates in https://github.com/STMicroelectronics/stm32-external-loader/tree/contrib. I am using STM32CubeIDE v 1.19.0 and STM Cube Programmer v 2.21.0.

When I try to use the external loader in the CubeProgrammer, I can see (with some debugging) that the Init() function is called by STM Programmer, but fails quite early during HAL_Init(). With further debugging, I found out that the reason for the failing HAL functions seems to be the missing initialization of the global variables, i.e. the variables in the .data and .bss section of the linker file. 

While I can initialize the .bss section manually (by setting the section to Zero), I have no idea how to force a correct initialization of the variables in the .data section. In "normal" apps starting from the Reset_Handler, this is handled by the startup script (startup_stm32u375rgixq.s). How can this be achieved in the external loader context?

Any hint on how to get this working would be highly appreciated.

0 REPLIES 0