How to reset the PSP/MSP (process/master stack pointers) mode in the PSoC6 bootloader?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
BeMb_4626836
Level 1
Level 1
First like given Welcome!

Hi guys,
I am using CE220959:

CE220959 – PSoC 6 MCU Bluetooth Low Energy (BLE) Device Firmware Update (DFU) with External Memory

How to reset the PSP/MSP (process/master stack pointers) mode in this PSoC6 bootloader?
Please point me to the exact line of code

Thanks
Ben

0 Likes
1 Solution

In cmsis_gcc.h, you find:

__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)

{

  __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );

}

and

__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)

{

  __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );

}

In cy_dfu.c, Cy_DFU_SwitchToApp, which is called by CY_DFU_OnResetApp0, switches to App1 by calling SwitchToApp. This function writes to the MSP register.

View solution in original post

5 Replies
SudheeshK
Moderator
Moderator
Moderator
250 sign-ins First question asked 750 replies posted

Hello,

Could you please clarify, why do you want to reset PSP and MSP in CE220959?

Thanks and Regards,

Sudheesh

0 Likes

Hello,
the bootloader of this testcase does not work.

We have been trying for weeks to make this bootloader work on external memory.

We have a violation like this one:

CM4 FAULT!!

SCB->CFSR = 0x00020000

r0 = 0x00000000

r1 = 0x08047784

r2 = 0x00000001

r3 = 0x00000113

r12 = 0x100c8248

lr = 0xfffffff1

pc = 0x08047800

psr = 0x40000040

The ARM CM4 documentation states that this usually a result of missing to reset PSP/MSP once APP0 gives control to APP1

Hope this clarifies

Thanks
Ben

0 Likes

Hi Sudheesh,

any feedback on this?

Thanks and Regards,

Ben

0 Likes

In cmsis_gcc.h, you find:

__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)

{

  __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );

}

and

__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)

{

  __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );

}

In cy_dfu.c, Cy_DFU_SwitchToApp, which is called by CY_DFU_OnResetApp0, switches to App1 by calling SwitchToApp. This function writes to the MSP register.

Thank you very much for your feedback Rudolfo. I will check and comment.

0 Likes