pyocd / pyOCD

Open source Python library for programming and debugging Arm Cortex-M microcontrollers
https://pyocd.io
Apache License 2.0
1.08k stars 472 forks source link

Unable to reset stm32wba52cgux using Python API. #1658

Open Vadim-klika opened 5 months ago

Vadim-klika commented 5 months ago

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?