Hi,
To find the reset source you can read:
RGM FES / DES registers to find the reset root cause.
I expect your situation is:
After your Power on reset your device is running and them it is reset.
Then do attach with debugger and read RGM FES / DES registers.
This will tell you your reset cause.
Peter