question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pyocd-gdbserver crashes on Raspberry Pi

See original GitHub issue

Reproduce steps:

  1. Install pyOCD package
  2. Run server with command “sudo pyocd-gdbserver -p 3333” for instance

Expected result:

No crash

Actual result:

Crash almost immediately.

Reproducibility:

Always.

ref: IOTSYST-2177

with rasbian image:

pi@flashdev2:~ $ sudo pyocd-gdbserver --version
0.8.1a2.dev22
pi@flashdev2:~ $ sudo pyocd-gdbserver -d debug -p 3333 -b 0240000031754e45003c00189486002ade61000097969900
DEBUG:root:init board <pyOCD.board.mbed_board.MbedBoard object at 0x762070f0>
DEBUG:root:Started loading SVD
DEBUG:root:Completed loading SVD
INFO:root:DAP SWD MODE initialized
DEBUG:root:closing interface
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "build/bdist.linux-armv7l/egg/pyOCD/pyDAPAccess/interface/pyusb_backend.py", line 140, in rx_task
    self.rcv_data.append(self.ep_in.read(self.ep_in.wMaxPacketSize, 10 * 1000))
  File "build/bdist.linux-armv7l/egg/usb/core.py", line 402, in read
    return self.device.read(self, size_or_buffer, timeout)
  File "build/bdist.linux-armv7l/egg/usb/core.py", line 988, in read
    self.__get_timeout(timeout))
  File "build/bdist.linux-armv7l/egg/usb/backend/libusb1.py", line 851, in intr_read
    timeout)
  File "build/bdist.linux-armv7l/egg/usb/backend/libusb1.py", line 936, in __read
    _check(retval)
  File "build/bdist.linux-armv7l/egg/usb/backend/libusb1.py", line 595, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
USBError: [Errno 32] Pipe error

uncaught exception: Device 0240000031754e45003c00189486002ade61000097969900 read thread exited
Traceback (most recent call last):
  File "build/bdist.linux-armv7l/egg/pyOCD/tools/gdb_server.py", line 265, in run
    frequency=self.args.frequency)
  File "build/bdist.linux-armv7l/egg/pyOCD/board/mbed_board.py", line 265, in chooseBoard
    mbed.init()
  File "build/bdist.linux-armv7l/egg/pyOCD/board/board.py", line 50, in init
    self.target.init()
  File "build/bdist.linux-armv7l/egg/pyOCD/target/family/target_kinetis.py", line 62, in init
    self.mdm_ap.init(False)
  File "build/bdist.linux-armv7l/egg/pyOCD/coresight/ap.py", line 86, in init
    self.rom_addr = self.read_reg(AP_ROM_TABLE_ADDR_REG)
  File "build/bdist.linux-armv7l/egg/pyOCD/coresight/ap.py", line 100, in read_reg
    return self.dp.readAP((self.ap_num << APSEL_SHIFT) | addr, now)
  File "build/bdist.linux-armv7l/egg/pyOCD/coresight/dap.py", line 293, in readAP
    return readAPCb()
  File "build/bdist.linux-armv7l/egg/pyOCD/coresight/dap.py", line 284, in readAPCb
    result = result_cb()
  File "build/bdist.linux-armv7l/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 652, in read_reg_cb
    res = transfer.get_result()
  File "build/bdist.linux-armv7l/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 119, in get_result
    self.daplink.flush()
  File "build/bdist.linux-armv7l/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 583, in flush
    self._read_packet()
  File "build/bdist.linux-armv7l/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 736, in _read_packet
    raw_data = self._interface.read()
  File "build/bdist.linux-armv7l/egg/pyOCD/pyDAPAccess/interface/pyusb_backend.py", line 203, in read
    self.serial_number)
DeviceError: Device 0240000031754e45003c00189486002ade61000097969900 read thread exited

and with archlinux:

[alarm@alarm ~]$ sudo pyocd-gdbserver --allow-remote
INFO:root:DAP SWD MODE initialized
INFO:root:K64F not in secure state
INFO:root:ROM table #0 @ 0xe00ff000 cidr=b105100d pidr=4000bb4c4
INFO:root:[0]<e000e000:SCS-M4 cidr=b105e00d, pidr=4000bb00c, class=14>
INFO:root:[1]<e0001000:DWT cidr=b105e00d, pidr=4003bb002, class=14>
INFO:root:[2]<e0002000:FPB cidr=b105e00d, pidr=4002bb003, class=14>
INFO:root:[3]<e0000000:ITM cidr=b105e00d, pidr=4003bb001, class=14>
INFO:root:[4]<e0040000:TPIU-M4 cidr=b105900d, pidr=4000bb9a1, class=9, devtype=11, devid=ca1>
INFO:root:[5]<e0041000:ETM-M4 cidr=b105900d, pidr=4000bb925, class=9, devtype=13, devid=0>
INFO:root:[6]<e0042000:ETB cidr=b105900d, pidr=4003bb907, class=9, devtype=21, devid=0>
INFO:root:[7]<e0043000:CSTF cidr=b105900d, pidr=4001bb908, class=9, devtype=12, devid=28>
INFO:root:CPU core is Cortex-M4
INFO:root:FPU present
INFO:root:6 hardware breakpoints, 4 literal comparators
INFO:root:4 hardware watchpoints
INFO:root:Telnet: server started on port 4444
INFO:root:GDB server started at port:3333
INFO:root:One client connected!
INFO:root:DAP SWD MODE initialized
INFO:root:K64F not in secure state
INFO:root:ROM table #0 @ 0xe00ff000 cidr=b105100d pidr=4000bb4c4
INFO:root:[0]<e000e000:SCS-M4 cidr=b105e00d, pidr=4000bb00c, class=14>
INFO:root:[1]<e0001000:DWT cidr=b105e00d, pidr=4003bb002, class=14>
INFO:root:[2]<e0002000:FPB cidr=b105e00d, pidr=4002bb003, class=14>
INFO:root:[3]<e0000000:ITM cidr=b105e00d, pidr=4003bb001, class=14>
INFO:root:[4]<e0040000:TPIU-M4 cidr=b105900d, pidr=4000bb9a1, class=9, devtype=11, devid=ca1>
INFO:root:[5]<e0041000:ETM-M4 cidr=b105900d, pidr=4000bb925, class=9, devtype=13, devid=0>
INFO:root:[6]<e0042000:ETB cidr=b105900d, pidr=4003bb907, class=9, devtype=21, devid=0>
INFO:root:[7]<e0043000:CSTF cidr=b105900d, pidr=4001bb908, class=9, devtype=12, devid=28>
INFO:root:CPU core is Cortex-M4
INFO:root:FPU present
INFO:root:6 hardware breakpoints, 4 literal comparators
INFO:root:4 hardware watchpoints
INFO:root:Semihosting enabled
ERROR:root:Unhandled exception in handleMsg: DAP_TRANSFER_BLOCK response error
Traceback (most recent call last):
  File "build/bdist.linux-aarch64/egg/pyOCD/gdbserver/gdbserver.py", line 468, in handleMsg
    return self.vCommand(msg[2:]), 0
  File "build/bdist.linux-aarch64/egg/pyOCD/gdbserver/gdbserver.py", line 630, in vCommand
    return self.flashOp(data)
  File "build/bdist.linux-aarch64/egg/pyOCD/gdbserver/gdbserver.py", line 756, in flashOp
    self.flashBuilder.program(chip_erase=self.chip_erase, progress_cb=progress_cb, fast_verify=self.fast_program)
  File "build/bdist.linux-aarch64/egg/pyOCD/flash/flash_builder.py", line 212, in program
    self.flash.init()
  File "build/bdist.linux-aarch64/egg/pyOCD/flash/flash.py", line 116, in init
    result = self.callFunctionAndWait(self.flash_algo['pc_init'], init=True)
  File "build/bdist.linux-aarch64/egg/pyOCD/flash/flash.py", line 396, in callFunctionAndWait
    self.callFunction(pc, r0, r1, r2, r3, init)
  File "build/bdist.linux-aarch64/egg/pyOCD/flash/flash.py", line 319, in callFunction
    self.target.writeBlockMemoryAligned32(self.flash_algo['analyzer_address'], analyzer)
  File "build/bdist.linux-aarch64/egg/pyOCD/core/coresight_target.py", line 116, in writeBlockMemoryAligned32
    return self.selected_core.writeBlockMemoryAligned32(addr, data)
  File "build/bdist.linux-aarch64/egg/pyOCD/coresight/cortex_m.py", line 438, in writeBlockMemoryAligned32
    self.ap.writeBlockMemoryAligned32(addr, data)
  File "build/bdist.linux-aarch64/egg/pyOCD/coresight/ap.py", line 359, in writeBlockMemoryAligned32
    self._writeBlock32(addr, data[:n/4])
  File "build/bdist.linux-aarch64/egg/pyOCD/coresight/ap.py", line 208, in _writeBlock32
    self.link.reg_write_repeat(len(data), reg, data)
  File "build/bdist.linux-aarch64/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 674, in reg_write_repeat
    self._write(dap_index, num_repeats, request, data_array)
  File "build/bdist.linux-aarch64/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 840, in _write
    self._send_packet()
  File "build/bdist.linux-aarch64/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 783, in _send_packet
    self._read_packet()
  File "build/bdist.linux-aarch64/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 738, in _read_packet
    decoded_data = cmd.decode_data(raw_data)
  File "build/bdist.linux-aarch64/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 417, in decode_data
    data = self._decode_transfer_block_data(data)
  File "build/bdist.linux-aarch64/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 377, in _decode_transfer_block_data
    raise ValueError('DAP_TRANSFER_BLOCK response error')
ValueError: DAP_TRANSFER_BLOCK response error
INFO:root:Client detached
INFO:root:Telnet: server stopped
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "build/bdist.linux-aarch64/egg/pyOCD/pyDAPAccess/interface/pyusb_backend.py", line 140, in rx_task
    self.rcv_data.append(self.ep_in.read(self.ep_in.wMaxPacketSize, 10 * 1000))
  File "build/bdist.linux-aarch64/egg/usb/core.py", line 402, in read
    return self.device.read(self, size_or_buffer, timeout)
  File "build/bdist.linux-aarch64/egg/usb/core.py", line 988, in read
    self.__get_timeout(timeout))
  File "build/bdist.linux-aarch64/egg/usb/backend/libusb1.py", line 851, in intr_read
    timeout)
  File "build/bdist.linux-aarch64/egg/usb/backend/libusb1.py", line 936, in __read
    _check(retval)
  File "build/bdist.linux-aarch64/egg/usb/backend/libusb1.py", line 595, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
USBError: [Errno 110] Operation timed out

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jupecommented, Apr 28, 2017

This might be actually RPiv3 usb driver issue and nothing to do with pyOCD, but that is current feeling based on tests that we did. Anyway, I propose to mention in readme/documentation that pyOCD doesn’t work with RPi.

0reactions
rmu75commented, Jul 30, 2019

Just FYI, after some woes regarding installation of cmsis-pack-manager, and a separate issue with USB which I still have to investigate, pyocd seems to run fine on a Raspberry Pi, ubuntu 18.04.2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pyocd-gdbserver crashes on Raspberry Pi · Issue #295 - GitHub
Install pyOCD package; Run server with command "sudo pyocd-gdbserver -p 3333" for instance. Expected result: No crash. Actual result: Crash ...
Read more >
gdb crashes when trying to start a debugging session
This bug log applies to Ubuntu Mate for raspberry PI. ... I've first noticed the segfault during remote debugging, using gdbserver,
Read more >
Intermittent OpenOCD crashes with Picoprobe
I've tried the picoprobe uf2 image from the Raspberry Pi website and building it from source. I launch OpenOCD from a simple script:...
Read more >
pyocd - PyPI
gdbserver : GDB remote server allows you to debug using gdb via either the console ... PE Micro Cyclone and Multilink; Raspberry Pi...
Read more >
ORBTrace Effort: Open Tool For Professional Debugging
There are some fairly powerful debugging facilities available on today's microcontrollers — if your code crashes mysteriously, chances are, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found