pyocd / pyocd/pyOCD

Hardware reset and halt on connect

Open
#698 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

new feature
Dominant language
Python
Stars
1.5k
Forks
560
Avg merge
1h 41m
Merged PRs (30d)
3

Description

Is there a way to connect to a device in sleep mode?
Can I issue a hardware reset, and halt the processor before trying to connect?

Currently I'm getting this error:

  File "C:\Python37\lib\site-packages\pyocd\core\session.py", line 367, in open
    self._board.init()
  File "C:\Python37\lib\site-packages\pyocd\board\board.py", line 83, in init
    self.target.init()
  File "C:\Python37\lib\site-packages\pyocd\core\coresight_target.py", line 158, in init
    seq.invoke()
  File "C:\Python37\lib\site-packages\pyocd\utility\sequencer.py", line 201, in invoke
    resultSequence = call()
  File "C:\Python37\lib\site-packages\pyocd\coresight\dap.py", line 85, in init
    self.link.connect()
  File "C:\Python37\lib\site-packages\pyocd\probe\stlink_probe.py", line 114, in connect
    self._link.enter_debug(STLink.Protocol.SWD)
  File "C:\Python37\lib\site-packages\pyocd\probe\stlink\stlink.py", line 256, in enter_debug
    self._check_status(response)
  File "C:\Python37\lib\site-packages\pyocd\probe\stlink\stlink.py", line 294, in _check_status
    raise exceptions.ProbeError(error_message)
pyocd.core.exceptions.ProbeError: STLink error (11): Debug power error

I've had this issue before using OpenOCD
Changing the following line in the device config file resolved it.

from: reset_config srst_nogate
to:   reset_config trst_and_srst srst_nogate connect_assert_srst

When first connecting and disconnecting the stlink-utility and then running the script there are no issues.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the reported connection path through pyocd/core/session.py, pyocd/board/board.py, pyocd/core/coresight_target.py, pyocd/coresight/dap.py, pyocd/probe/stlink_probe.py, and pyocd/probe/stlink/stlink.py. Compare the existing reset configuration handling with the requested connect-and-reset behavior and identify relevant tests or device configuration entry points. Done should be defined as reliably connecting to the affected sleeping device while supporting hardware reset and processor halt before connection.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools, embedded-iot
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.