I'm working in my custom application based on STM32L4.
Sometimes, a problem appears when trying to flash the device: If I try to flash it with Keil and Ulink2 interface, a message suddenly appears when trying to flash it, and it says that it is not possible to flash it. Being in this situation, if then I try to flash it via USB using Dfuse demo tool, a message telling 'device is read protected' appears. But then, using the same tool, if I try to upgrade it again, I'm able to flash it. Then, device is correctly flashed but data that I had in flash (protected area) is also erased.
As I have said, this is a thing that only appears sometimes.
So, what can be the reason of this behaviour? How can I avoit it?