Skip to main content
Visitor II
March 11, 2025
Solved

[STM32U5G9NJH6Q] Custom Boot / App SW [vmov s15, r3]

  • March 11, 2025
  • 1 reply
  • 441 views

Hi, I'm creating Boot sw & App sw in one board. which means, 2 independent STM32 Proj. runs in same Flash / RAM.

 

There is an issue when HAL_RCC_GetSysClockFreq() has been called. The first called sw, boot sw, doesn't make any trouble. but the second one, app sw which is jumped in by boot sw, make trouble when do [vmov s15, r3] assembly code. I've already checked Memory Map, Flash.ld, Vector ... etc. So obviously, there is no problem until [vmov s15, r3] will be done by app sw.

 

the first call of [vmov s15, r3] is triggered by [main()] - [SystemClock_Config()] - [HAL_RCC_GetSysClockFreq()]
fracn1 = (float_t)(uint32_t)(pllfracen * ((RCC->PLL1FRACR & RCC_PLL1FRACR_PLL1FRACN) >> \ RCC_PLL1FRACR_PLL1FRACN_Pos));

Strawberryrabbit_0-1741684796785.png

 

As result of [vmov s15, r3], MSP has been corrupted. Red box is the Stack Pointer, and Blue box is MSP. So blue box area should not be changed by [vmov s15, r3]. But as you can see, the Return Address has been corrupted after [vmov s15, r3] has been runned.

Strawberryrabbit_1-1741684892007.png

Strawberryrabbit_2-1741684980038.png


Any Possible Suggestion will be welcomed. Thank you.

 

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

    Control Register was not initialized when It jumps to App SW.

     

    	// to Reset Control Register
    	__ASM volatile ("MSR control, %0" : : "r" (0));

     

    I added this line to reset Coretex-m4 control register. it caused MSP PSP stack issue when jump in to new App sw Main func.

    1 reply

    StrawberryrabbitAuthorAnswer
    Visitor II
    March 17, 2025

    Control Register was not initialized when It jumps to App SW.

     

    	// to Reset Control Register
    	__ASM volatile ("MSR control, %0" : : "r" (0));

     

    I added this line to reset Coretex-m4 control register. it caused MSP PSP stack issue when jump in to new App sw Main func.