2022-11-18 02:57 AM
Hi. I have stm32L552xx that i need to program using SWD. I have to halt core, write some code to RAM, replace PC and run core. If some valid code exists on flash i have no problem. It works perfectly. But if i try to do the same thing on empty flash i come across a lockup.
steps:
check the registers
DHCSR = 0x0308 0000 -> S_LOCKUP (it's normal, because flash is empty )
PC = 0xffff fffe (Yes, this is the way it should be )
halt the core
DHCSR = 0x0003 0003 -> S_LOCKUP disappeared
Next, i relocate PC to RAM, write some code to RAM(it works if flash is not empty), clear debug fault Status (DFSR) and run the core and get LOCKUP (DHCSR = 0x0508 0001)
CFSR (0x0000 8200)
BFAR (0xffff ffc8)
There is no help from DEMCR_VC_CORERESET and AIRCR_SYSRESETREQ
What I forgot to do?
Thank you