pylink icon indicating copy to clipboard operation
pylink copied to clipboard

How to set or remove read protection of stm32

Open as564335sa opened this issue 4 years ago • 6 comments

Hi, When I connect a chip that has read protection set, it will throw an exception,How can I set or remove read protection like jflash?

as564335sa avatar Mar 31 '20 05:03 as564335sa

It should happen automatically if you've specified the device correctly. There are unlock methods, but I've only implemented the unlock sequence for the Kinetis chip family.

hkpeprah avatar Apr 14 '20 18:04 hkpeprah

Hi: I just fix this problem, the remove need two steps: 1、modify the pylink source code 2、

def unsecure_device_hook(title, msg, flags):
    return pylink.enums.JLinkFlags.DLG_BUTTON_YES

...
jlink = pylink.JLink(unsecure_hook=unsecure_device_hook)
...

Moral-ecomo avatar Apr 23 '20 12:04 Moral-ecomo

Whoops, you are correct, we by default specify NO to unlock automatically.

hkpeprah avatar Apr 23 '20 15:04 hkpeprah

Hi, I successfully cleared the read protection with @Moral-ecomo method. However, a new problem has arisen. During continuous programming, Once in every two programming, jlink.reset() does not work, but no exception is thrown. Why this problem occurs,and how can I solve it

qtvbab avatar May 12 '20 08:05 qtvbab

Which exception is thrown? If you run with logging enabled, you should see more helpful messages:

import logging

logging.basicConfig(level=logging.DEBUG)

hkpeprah avatar May 12 '20 15:05 hkpeprah

Oh. I found the reason: If the read protection is set while the debugger is still connected through JTAG/SWD, apply a POR (power-on reset) instead of a system reset (without debugger connection). So after the second programming, the chip cannot start after reset().

qtvbab avatar May 13 '20 03:05 qtvbab