pylink icon indicating copy to clipboard operation
pylink copied to clipboard

erase() and flash_file functions are not working

Open Dave5217 opened this issue 2 years ago • 3 comments

I am trying to automate the erasing and reflashing of a chip but none of them are working. Here is my code:

import pylink import time

error = '' file = 'example.bin' jlink = pylink.JLink()

jlink.open(serial_no=601011318) jlink.set_tif(1)

try: jlink.connect('CORTEX-M0', 4000) jlink.erase() sleep(5) jlink.flash_file(file,0x0)

except error: print('Couldn't do it')

finally: jlink.close()

The erase function doesn't erase the chip but throws no exception. The flash_flie function throws the following exception: JLinkFlashException: Could not write target memory.

Dave5217 avatar Jun 17 '22 00:06 Dave5217

You likely need to stop the core before flashing it using: .halt().

hkpeprah avatar Jun 17 '22 18:06 hkpeprah

I saw that the method checks if the core is halted and halts it if it's not, but anyway I tried to stop the core first and got the same exception

Dave5217 avatar Jun 17 '22 20:06 Dave5217

Hm, usually an error like that happens if the device isn't stopped, or if it has to be reset in a special mode (see here for troubleshooting ideas). If you run with verbosity enabled, you should be able to see more logs that should point to where the issue is (e.g. "Failed to Stop Core").

hkpeprah avatar Jun 20 '22 14:06 hkpeprah