pyocd / pyOCD

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

usb.core.USBTimeoutError: [Errno 110] Operation timed out #1039

Closed mttbx closed 3 years ago

mttbx commented 3 years ago

I was porting DAPLink to my own driver. When I run pyocd I get this error. usb.core.USBTimeoutError: [Errno 110] Operation timed out I also run openocd, here's the error.

Info : 226 87 cmsis_dap_usb.c:1105 cmsis_dap_init(): CMSIS-DAP: Interface ready
Debug: 227 87 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 228 87 core.c:1789 adapter_khz_to_speed(): have interface set up
Debug: 229 89 core.c:1785 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 230 89 core.c:1789 adapter_khz_to_speed(): have interface set up
Info : 231 89 core.c:1565 adapter_init(): clock speed 1000 kHz
Debug: 232 89 openocd.c:141 handle_init_command(): Debug Adapter init complete
Debug: 233 89 command.c:146 script_debug(): command - transport init
Debug: 235 89 transport.c:239 handle_transport_init(): handle_transport_init
Debug: 236 89 command.c:146 script_debug(): command - dap init
Debug: 238 89 arm_dap.c:106 dap_init_all(): Initializing all DAPs ...
Debug: 239 93 cmsis_dap_usb.c:925 cmsis_dap_swd_switch_seq(): JTAG-to-SWD
Info : 240 99 adi_v5_swd.c:136 swd_connect(): SWD DPIDR 0x1ba01477
Debug: 241 99 arm_adi_v5.c:653 dap_dp_init(): stm32f1x.dap
Debug: 242 101 arm_adi_v5.c:698 dap_dp_init(): DAP: wait CDBGPWRUPACK
Debug: 243 101 arm_adi_v5.h:506 dap_dp_poll_register(): DAP: poll 4, mask 0x20000000, value 0x20000000
Error: 244 5295 cmsis_dap_usb.c:378 cmsis_dap_usb_write(): error writing data: (null)
Debug: 245 5295 command.c:626 run_command(): Command 'dap init' failed with error code -4

Noticed that the debugger being inited successfully. But it failed because of the timeout error of the usb. In the usb driver on the device, I just called DAP_ProcessCommand and then responded the result. I don't know why this can't work. Can you give me a hint?

mttbx commented 3 years ago

Here's some info that pyocd read before:

0002099:INFO:board:Target type is cortex_m
0002199:INFO:dap:DP IDR = 0x1ba01477
0002243:INFO:dap:AP#0 IDR = 0x14770011
0003244:ERROR:__main__:uncaught exception: [Errno 110] Operation timed out
mttbx commented 3 years ago

I just get it worked. I put all the job into the irq. I used to use a realtime os task and a queue to do the job. So the question becomes why the realtime task did't work? And how can I make it right?