pyocd / pyocd/pyOCD

Unable to reset stm32wba52cgux using Python API.

Open
#1,658 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hello,
I am exploring pyocd and trying to write a simple script to reset my NUCLEO-WBA52CG board.

from pyocd.core.helpers import ConnectHelper

if __name__ == '__main__':
    session = ConnectHelper.session_with_chosen_probe(
        unique_id="<my_unique_id>",
        options={
            "target_override": "stm32wba52cgux",
            "dap_protocol": "swd",
            "reset_type": "hw"
        }
    )
    target = session.target
    print(f'TARGET IS {target}')
    target.reset()

    # Close the session and connection.
    session.close()

But I have got the following AssertionError:

TARGET IS <pyocd.target.pack.pack_target.Stm32wba52cgux object at 0x0000026694B00510>
Traceback (most recent call last):
  File "D:\projects\sidewalk\stmc-sid-autotests\qualification\clients\pyoc_client.py", line 14, in <module>
    target.reset()
  File "D:\projects\sidewalk\stmc-sid-autotests\venv\Lib\site-packages\pyocd\coresight\coresight_target.py", line 338, in reset
    self.dp.reset()
  File "D:\projects\sidewalk\stmc-sid-autotests\venv\Lib\site-packages\pyocd\coresight\dap.py", line 665, in reset
    self.probe.reset()
  File "D:\projects\sidewalk\stmc-sid-autotests\venv\Lib\site-packages\pyocd\probe\stlink_probe.py", line 200, in reset
    self._link.drive_nreset(True)
  File "D:\projects\sidewalk\stmc-sid-autotests\venv\Lib\site-packages\pyocd\probe\stlink\stlink.py", line 354, in drive_nreset
    response = self._device.transfer([Commands.JTAG_COMMAND, Commands.JTAG_DRIVE_NRST, value], readSize=2)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\projects\sidewalk\stmc-sid-autotests\venv\Lib\site-packages\pyocd\probe\stlink\usb.py", line 231, in transfer
    assert self._ep_out
AssertionError

On the other hand, it works well when I try it with CLI:

pyocd reset -m hw -t stm32wba52cgux -u <my_unique_id>

What am I doing wrong?

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 with ConnectHelper.session_with_chosen_probe and target.reset, then compare the Python API path with the CLI reset command shown in the report. Reproduce the failure on the NUCLEO-WBA52CG and inspect why stlink_probe.py reaches transfer() without _ep_out; done means the API reset works for this board and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.