Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to STM32F103 with JTAG #1722

Open
HiFiPhile opened this issue Aug 30, 2024 · 0 comments
Open

Unable to connect to STM32F103 with JTAG #1722

HiFiPhile opened this issue Aug 30, 2024 · 0 comments

Comments

@HiFiPhile
Copy link

Environment

  • Windows 10 22H2
  • Python 3.12
  • pyOCD 0.36.0
  • DIY CMSIS-DAP v2 probe
  • J-Link V9 probe
  • IAR EWARM 9.5
  • OpenOCD 0.12.0-4

Issue

pyOCD unable to connect to STM32F103 with JTAG, while SWD is working.

To rule out other issues all SW-HW combinations are tested (eg. CMSIS-DAP + OpenOCD in JTAG, J-Link + IAR in SWD, etc).

For both J-Link V9 and CMSIS-DAP probe pyOCD doesn't work in JTAG mode, all other combinations are working.

Error with J-Link:

$ pyocd load --target stm32f103rc -O dap_protocol=jtag -f 1000000 -a 0x20000000 "debug.bin" -v -O reset_type=hw
0000629 I Target type is stm32f103rc [board]
0000657 I DP IDR = 0x00000000 (v0 rev0) [dap]
0005668 C No cores were discovered! [__main__]

Error with CMSIS-DAP:

$ pyocd load --target stm32f103rc -O dap_protocol=jtag -f 1000000 -a 0x20000000 "debug.bin" -v -O reset_type=hw
0000648 I Target type is stm32f103rc [board]
0000741 C Unexpected ACK value (0) returned by probe [__main__]

Log

0000638 D Project directory: C:\Users\M[session]
0000638 D Project directory: C:\Users\M[session]
0000683 D CMSIS-DAP v2 probe 7C6FC9A3A144F536: protocol version 2.1.2 [dap_access_cmsis_dap]
0000685 I Target type is stm32f103rc [board]
0000731 D Running task load_svd [sequencer]
0000731 D Running task pre_connect [sequencer]
0000731 D Running task dp_init [sequencer]
0000731 D Running task lock_probe [sequencer]
0000732 D Running task get_probe_capabilities [sequencer]
0000732 D Running task connect [sequencer]
0000733 D Using JTAG wire protocol [dap]
0000741 D Sending deprecated SWJ sequence to select JTAG [swj]
0000778 D DP IDCODE read failed; resending SWJ sequence (use dormant=False) [dap]
0000778 D Sending deprecated SWJ sequence to select JTAG [swj]
0000779 D DP IDCODE read failed; resending SWJ sequence (use dormant=False) [dap]
0000779 D Sending SWJ sequence to select JTAG ; using dormant state [swj]
0000780 D DP IDCODE read failed; resending SWJ sequence (use dormant=False) [dap]
0000780 D Sending SWJ sequence to select JTAG ; using dormant state [swj]
0000781 D DP IDCODE read failed; resending SWJ sequence (use dormant=False) [dap]
0000781 D uninit session <pyocd.core.session.Session object at 0x000001CCF50B5AF0> [session]
0000782 C Unexpected ACK value (0) returned by probe [__main__]
Traceback (most recent call last):
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\probe\cmsis_dap_probe.py", line 539, in read_dp
    result = self._link.read_reg(reg_id, now=now)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\probe\pydapaccess\dap_access_cmsis_dap.py", line 1086, in read_reg
    return read_reg_cb()
           ^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\probe\pydapaccess\dap_access_cmsis_dap.py", line 1080, in read_reg_cb
    res = transfer.get_result()
          ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\probe\pydapaccess\dap_access_cmsis_dap.py", line 161, in get_result
    self.daplink.flush()
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\utility\concurrency.py", line 29, in _locking
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\probe\pydapaccess\dap_access_cmsis_dap.py", line 885, in flush
    self._read_packet()
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\utility\concurrency.py", line 29, in _locking
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\probe\pydapaccess\dap_access_cmsis_dap.py", line 1166, in _read_packet
    decoded_data = cmd.decode_data(raw_data)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\probe\pydapaccess\dap_access_cmsis_dap.py", line 482, in decode_data
    data = self._decode_transfer_block_data(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\probe\pydapaccess\dap_access_cmsis_dap.py", line 451, in _decode_transfer_block_data
    self._check_response(data[3])
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\probe\pydapaccess\dap_access_cmsis_dap.py", line 374, in _check_response
    raise DAPAccessIntf.TransferError("Unexpected ACK value (%d) returned by probe" % ack)
pyocd.probe.pydapaccess.dap_access_api.DAPAccessIntf.TransferError: Unexpected ACK value (0) returned by probe

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\__main__.py", line 161, in run
    status = cmd.invoke()
             ^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\subcommands\load_cmd.py", line 100, in invoke
    with session:
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\core\session.py", line 415, in __enter__
    self.open()
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\core\session.py", line 553, in open
    self._board.init()
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\board\board.py", line 143, in init
    self.target.init()
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\coresight\coresight_target.py", line 123, in init
    super().init()
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\core\soc_target.py", line 174, in init
    seq.invoke()
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\utility\sequencer.py", line 213, in invoke
    resultSequence.invoke()
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\utility\sequencer.py", line 208, in invoke
    resultSequence = call()
                     ^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\coresight\dap.py", line 467, in _connect
    connector.connect()
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\coresight\dap.py", line 257, in connect
    self._idr = self.read_idr()
                ^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\coresight\dap.py", line 286, in read_idr
    dpidr = self._probe.read_dp(DP_IDR, now=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\pyocd\probe\cmsis_dap_probe.py", line 542, in read_dp
    raise self._convert_exception(error) from error
pyocd.core.exceptions.TransferError: Unexpected ACK value (0) returned by probe

Capture

I've captured the traffic of pyOCD + CMSIS-DAP and OpenOCD + CMSIS-DAP.

Open with DSView :
jtag.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant