This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem un-securing Freescale KEA chip using ULINK2

The issue: I need to try twice to flash my Freescale chip to be able to reprogram it once it has been secured.

The issue occurs after I flash the chip with the flash security register value: 0x01xxxx01 (flash secure, no backdoor key).

My setup:
- ULINK2 programmer (firmware version 2.03)
- Keil UVision 5.17
- Freescale S9KEAZN64 chip connected to programmer using pins SWDIO, SWDCLK, RST, GND and VCC
My firmware is using the SWD pins and therefore reprogramming them in the first steps of our main().

UVision has several options available but none of those we tried worked as it should. There are always some error message. They differ depending on the configuration used.

I have singled out a couple of settings that influence the behavior:
- whether or not the chip is already secured prior to flashing
- whether we select the option 'under reset' or 'with pre-reset' in UVision
- whether our code is disabling (reprogramming them for other purpose) the SWD pins or not

I want to be able to re-program our chip after it has been secured and I would rather reprogram the SWD pins when initializing all other peripherals. For that reason I will describe this case more in details.
What I expect is that UVision finds out that the chip is secured and asks to perform a mass erase before flashing. We found online recommendations to use the option 'under reset' with 'hardware reset'. This however only produces an error:
"Cannot access memory (@0xf0002ff0, Read, Acc size: 4 byte)"
After this, the programmer keeps pulling the reset line low for very short time, regularly (pulse low for 5us every 6ms).
If instead of using 'under reset' we use the 'pre-reset' option, the error becomes:
"SWD communication error"

I also tried those with and without a pulldown on SWDCLK without any visible difference.

For now I have found a workaround: if I use those 2 methods one after another, for some reason the regular pulling of the reset line (because of 'under reset') helps the 'pre-reset' and I get the expected behavior instead of the "SWD communication error". But this is not a very nice and sustainable solution...

Have you ever heard of a similar problem? Do you have an idea on what could be the problem? Do you know of any setting for Keil's UVision that could solve this issue?

P.S. This has been tried on 2 different computers with 2 different ULINK2 programmers with exact same behavior.