square / pylink

Python Library for device debugging/programming via J-Link
https://pylink.readthedocs.io/en/latest/
Other
346 stars 127 forks source link

Add JLink Resume Command #120

Closed NickolasLapp closed 2 years ago

NickolasLapp commented 2 years ago

This PR adds a resume() command to enable resuming JLink operation when a core is halted.

This functionality is needed, in addition to being able to programmatically halt and resume operation on the core, because I found that some MCUs are automatically halted by JLink after a call to jlink.connect(). The only way I could find to get the CPU to continue (without resetting) was to add a call to JLINKARM_Go after the connection completed.

CLAassistant commented 2 years ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


NickolasLapp seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

hkpeprah commented 2 years ago

Hello @NickolasLapp, thank you for the submission! However, this functionality already exists under restart() (see documentation here). Please let me know if this doesn't address your use case.

NickolasLapp commented 2 years ago

Hello @NickolasLapp, thank you for the submission! However, this functionality already exists under restart() (see documentation here). Please let me know if this doesn't address your use case.

Thanks a lot for the quick response! I saw this function was implemented and is similar. After trying it out, it does seem to work! I think maybe the documentation (especially about the simulated instructions: https://github.com/square/pylink/blob/a2d9fbd3add62ffd06ba737c5ea82b8491fdc425/pylink/jlink.py#L2293-L2294) was slightly unclear to me.

Maybe this is just a misreading on my part, but if you agree maybe the documentation here could be slightly updated? In any case this seems to resolve my issue so feel free to close this PR.

hkpeprah commented 2 years ago

Yah, the documentation could be better; it would probably be better if it said re-starts the CPU from the current instruction it is halted on; the num_instructions is the number of instructions to skip.