在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
芯片精品文章合集(500篇!) 创芯人才网--重磅上线啦!
查看: 611|回复: 0

[求助] Openocd 无法连接 gdb

[复制链接]
发表于 2024-8-6 22:52:01 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
问题概要:
仿真蜂鸟 e203 SoC 并使用 gdb + Openocd 调试,但是 Openocd 不监听 gdb 端口,导致无法连接 gdb。
问题描述:
e203 使用 jtagdpi 作为 jtag 适配器,在 tb.v 中连接 jtagdpi 和 e203_soc_top 两个模块;Openocd 作为 gdb server。
在终端1运行 vcs 仿真 e203 ,同时在终端 2 运行 Openocd,以下是 Openocd 的配置文件(参考了开源代码):




  1. # "JTAG adapter" for simulation, exposed to OpenOCD through a TCP socket
  2. # speaking the remote_bitbang protocol. The adapter is implemented as
  3. # SystemVerilog DPI module.

  4. interface remote_bitbang
  5. remote_bitbang_port 44853
  6. remote_bitbang_host localhost

  7. # Target configuration for the hummingbird E203 chip

  8. if { [info exists CHIPNAME] } {
  9.    set  _CHIPNAME $CHIPNAME
  10. } else {
  11.    set  _CHIPNAME riscv
  12. }

  13. if { [info exists CPUTAPID ] } {
  14.    set _CPUTAPID $CPUTAPID
  15. } else {
  16.    set _CPUTAPID 0x1e200a6d
  17. }

  18. jtag newtap $_CHIPNAME tap -irlen 5 -expected-id $_CPUTAPID
  19. set _TARGETNAME $_CHIPNAME.tap
  20. target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME

  21. # Configure work area in on-chip SRAM
  22. $_TARGETNAME.0 configure -work-area-phys 0x9000e000 -work-area-size 1000 -work-area-backup 0

  23. riscv expose_csrs 3040-3071

  24. # Be verbose about GDB errors
  25. gdb_report_data_abort enable
  26. gdb_report_register_access_error enable

  27. # Increase timeouts in simulation
  28. riscv set_command_timeout_sec 1200


复制代码
配置文件设置 remote_bitbang_port 为 44853的原因是 jtagdpi 的监听端口是44853。
以下是终端 2 的输出信息:




  1. openocd -f openocd-e203.cfg -d
  2. Open On-Chip Debugger 0.12.0+dev-03884-g5afed58fc (2024-08-06-20:01)
  3. Licensed under GNU GPL v2
  4. For bug reports, read
  5.         http://openocd.org/doc/doxygen/bugs.html
  6. User : 3 1 options.c:52 configuration_output_handler(): debug_level: 3User : 4 1 options.c:52 configuration_output_handler():
  7. Debug: 5 1 options.c:346 parse_cmdline_args(): ARGV[0] = "openocd"
  8. Debug: 6 1 options.c:346 parse_cmdline_args(): ARGV[1] = "-f"
  9. Debug: 7 1 options.c:346 parse_cmdline_args(): ARGV[2] = "openocd-e203.cfg"
  10. Debug: 8 1 options.c:346 parse_cmdline_args(): ARGV[3] = "-d"
  11. Debug: 9 1 options.c:233 add_default_dirs(): bindir=/home/futreamer/software/openocd_install/bin
  12. Debug: 10 1 options.c:234 add_default_dirs(): pkgdatadir=/home/futreamer/software/openocd_install/share/openocd
  13. Debug: 11 1 options.c:235 add_default_dirs(): exepath=/home/futreamer/software/openocd_install/bin
  14. Debug: 12 1 options.c:236 add_default_dirs(): bin2data=../share/openocd
  15. Debug: 13 1 configuration.c:33 add_script_search_dir(): adding /home/futreamer/.config/openocd
  16. Debug: 14 1 configuration.c:33 add_script_search_dir(): adding /home/futreamer/.openocd
  17. Debug: 15 1 configuration.c:33 add_script_search_dir(): adding /home/futreamer/software/openocd_install/bin/../share/openocd/site
  18. Debug: 16 1 configuration.c:33 add_script_search_dir(): adding /home/futreamer/software/openocd_install/bin/../share/openocd/scripts
  19. Debug: 17 1 command.c:153 script_debug(): command - ocd_find openocd-e203.cfg
  20. Debug: 18 1 configuration.c:88 find_file(): found openocd-e203.cfg
  21. Debug: 19 1 command.c:153 script_debug(): command - echo DEPRECATED! use 'adapter driver' not 'interface'
  22. User : 20 1 command.c:678 handle_echo(): DEPRECATED! use 'adapter driver' not 'interface'
  23. Debug: 21 1 command.c:153 script_debug(): command - adapter driver remote_bitbang
  24. Debug: 22 1 command.c:153 script_debug(): command - echo DEPRECATED! use 'remote_bitbang port' not 'remote_bitbang_port'
  25. User : 23 1 command.c:678 handle_echo(): DEPRECATED! use 'remote_bitbang port' not 'remote_bitbang_port'
  26. Debug: 24 1 command.c:153 script_debug(): command - remote_bitbang port 44853
  27. Debug: 25 1 command.c:153 script_debug(): command - echo DEPRECATED! use 'remote_bitbang host' not 'remote_bitbang_host'
  28. User : 26 1 command.c:678 handle_echo(): DEPRECATED! use 'remote_bitbang host' not 'remote_bitbang_host'
  29. Debug: 27 1 command.c:153 script_debug(): command - remote_bitbang host localhost
  30. Debug: 28 1 command.c:153 script_debug(): command - transport select
  31. Info : 29 1 transport.c:267 handle_transport_select(): auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
  32. Debug: 30 1 command.c:153 script_debug(): command - transport select
  33. Debug: 31 1 command.c:153 script_debug(): command - jtag newtap riscv tap -irlen 5 -expected-id 0x1e200a6d
  34. Debug: 32 1 tcl.c:401 handle_jtag_newtap_args(): Creating New Tap, Chip: riscv, Tap: tap, Dotted: riscv.tap, 4 params
  35. Debug: 33 1 core.c:1474 jtag_tap_init(): Created Tap: riscv.tap [url=home.php?mod=space&uid=1801890]@[/url] abs position 0, irlen 5, capture: 0x1 mask: 0x3
  36. Debug: 34 1 command.c:153 script_debug(): command - target create riscv.tap.0 riscv -chain-position riscv.tap
  37. Debug: 35 1 target.c:2136 target_free_all_working_areas_restore(): freeing all working areas
  38. Debug: 36 1 riscv.c:445 riscv_create_target(): [riscv.tap.0] riscv_create_target()
  39. Debug: 37 1 command.c:153 script_debug(): command - riscv.tap.0 configure -work-area-phys 0x9000e000 -work-area-size 1000 -work-area-backup 0
  40. Debug: 38 1 target.c:2136 target_free_all_working_areas_restore(): freeing all working areas
  41. Debug: 39 1 target.c:2136 target_free_all_working_areas_restore(): freeing all working areas
  42. Debug: 40 1 target.c:2136 target_free_all_working_areas_restore(): freeing all working areas
  43. Debug: 41 1 command.c:153 script_debug(): command - riscv expose_csrs 3040-3071
  44. Debug: 42 1 command.c:153 script_debug(): command - gdb_report_data_abort enable
  45. Debug: 43 1 command.c:153 script_debug(): command - gdb_report_register_access_error enable
  46. Debug: 44 1 command.c:153 script_debug(): command - riscv set_command_timeout_sec 1200
  47. Info : 45 1 server.c:298 add_service(): Listening on port 6666 for tcl connections
  48. Info : 46 1 server.c:298 add_service(): Listening on port 4444 for telnet connections
  49. Debug: 47 1 command.c:153 script_debug(): command - init
  50. Debug: 48 1 command.c:153 script_debug(): command - target init
  51. Debug: 49 1 command.c:153 script_debug(): command - target names
  52. Debug: 50 1 command.c:153 script_debug(): command - riscv.tap.0 cget -event gdb-flash-erase-start
  53. Debug: 51 1 command.c:153 script_debug(): command - riscv.tap.0 configure -event gdb-flash-erase-start reset init
  54. Debug: 52 1 command.c:153 script_debug(): command - riscv.tap.0 cget -event gdb-flash-write-end
  55. Debug: 53 1 command.c:153 script_debug(): command - riscv.tap.0 configure -event gdb-flash-write-end reset halt
  56. Debug: 54 1 command.c:153 script_debug(): command - riscv.tap.0 cget -event gdb-attach
  57. Debug: 55 1 command.c:153 script_debug(): command - riscv.tap.0 configure -event gdb-attach halt 1000
  58. Debug: 56 1 target.c:1594 handle_target_init_command(): Initializing targets...
  59. Debug: 57 1 riscv.c:458 riscv_init_target(): [riscv.tap.0] riscv_init_target()
  60. Debug: 58 1 semihosting_common.c:107 semihosting_common_init():  
  61. Info : 59 2 remote_bitbang.c:378 remote_bitbang_init(): Initializing remote_bitbang driver
  62. Info : 60 2 remote_bitbang.c:300 remote_bitbang_init_tcp(): Connecting to localhost:44853
  63. Info : 61 2 remote_bitbang.c:389 remote_bitbang_init(): remote_bitbang driver initialized
  64. Info : 62 2 adapter.c:155 adapter_init(): Note: The adapter "remote_bitbang" doesn't support configurable speed
  65. Debug: 63 2 openocd.c:133 handle_init_command(): Debug Adapter init complete
  66. Debug: 64 2 command.c:153 script_debug(): command - transport init
  67. Debug: 65 2 transport.c:219 handle_transport_init(): handle_transport_init
  68. Debug: 66 2 core.c:830 jtag_add_reset(): SRST line released
  69. Debug: 67 2 core.c:855 jtag_add_reset(): TRST line released
  70. Debug: 68 2 core.c:328 jtag_call_event_callbacks(): jtag event: TAP reset
  71. Debug: 69 2 command.c:153 script_debug(): command - jtag arp_init
  72. Debug: 70 2 core.c:1509 jtag_init_inner(): Init JTAG chain
  73. Debug: 71 2 core.c:328 jtag_call_event_callbacks(): jtag event: TAP reset
  74. Debug: 72 2 core.c:1234 jtag_examine_chain(): DR scan interrogation for IDCODE/BYPASS
  75. Debug: 73 2 core.c:328 jtag_call_event_callbacks(): jtag event: TAP reset


复制代码
可以看出,启动 openocd 后,其未监听 gdb(3333) 端口,但是监听了 telnet (4444) 和 tcl (6666) 端口。
此外,Openocd 在 TAP(Test Access Port) 处卡住了,TAP reset了很多次,我分析是 jtag 的设备检测阶段没有通过,导致卡住?
当终止 SoC 的仿真时,Openocd 竟然开始监听了 gdb 端口,以下是新增的终端输出:




  1. Error: 74 12320 log.c:500 log_socket_error(): Error on socket 'remote_bitbang_fill_buf': errno==104, message: Connection reset by peer.
  2. Error: 75 12320 core.c:1554 jtag_init_inner(): Trying to use configured scan chain anyway...
  3. Debug: 76 12320 core.c:1364 jtag_validate_ircapture(): IR capture validation scan
  4. Debug: 77 12320 server.c:608 sig_handler(): Terminating on Signal 13
  5. Error: 78 12320 log.c:500 log_socket_error(): Error on socket 'remote_bitbang_putc': errno==32, message: Broken pipe.
  6. Debug: 79 12320 core.c:328 jtag_call_event_callbacks(): jtag event: TAP reset
  7. Debug: 80 12320 server.c:610 sig_handler(): Ignored extra Signal 13
  8. Error: 81 12320 log.c:500 log_socket_error(): Error on socket 'remote_bitbang_putc': errno==32, message: Broken pipe.
  9. Warn : 82 12320 core.c:1577 jtag_init_inner(): Bypassing JTAG setup events due to errors
  10. Debug: 83 12320 command.c:153 script_debug(): command - dap init
  11. Debug: 84 12320 log.c:408 gdb_timeout_warning(): keep_alive() was not invoked in the 1000 ms timelimit (12320 ms). This may cause trouble with GDB connections.
  12. Debug: 85 12320 arm_dap.c:96 dap_init_all(): Initializing all DAPs ...
  13. Debug: 86 12320 openocd.c:150 handle_init_command(): Examining targets...
  14. Debug: 87 12320 target.c:675 target_examine_one(): [riscv.tap.0] Examination started
  15. Debug: 88 12320 target.c:1780 target_call_event_callbacks(): target event 19 (examine-start) for core riscv.tap.0
  16. Debug: 89 12320 riscv.c:2161 riscv_examine(): [riscv.tap.0] Starting examination
  17. Debug: 90 12320 server.c:610 sig_handler(): Ignored extra Signal 13
  18. Error: 91 12320 log.c:500 log_socket_error(): Error on socket 'remote_bitbang_putc': errno==32, message: Broken pipe.
  19. Error: 92 12320 riscv.c:409 dtmcontrol_scan(): [riscv.tap.0] dtmcontrol scan failed, error code = -4
  20. Error: 93 12320 riscv.c:2172 riscv_examine(): [riscv.tap.0] Could not read dtmcontrol. Check JTAG connectivity/board power.
  21. Error: 94 12320 target.c:681 target_examine_one(): [riscv.tap.0] Examination failed
  22. Debug: 95 12320 target.c:682 target_examine_one(): [riscv.tap.0] examine() returned error code -4
  23. Debug: 96 12320 target.c:1780 target_call_event_callbacks(): target event 20 (examine-fail) for core riscv.tap.0
  24. Warn : 97 12320 target.c:739 target_examine(): target riscv.tap.0 examination failed
  25. Debug: 98 12320 openocd.c:152 handle_init_command(): target examination failed
  26. Debug: 99 12320 command.c:153 script_debug(): command - flash init
  27. Debug: 100 12320 tcl.c:1365 handle_flash_init_command(): Initializing flash devices...
  28. Debug: 101 12320 command.c:153 script_debug(): command - nand init
  29. Debug: 102 12320 tcl.c:484 handle_nand_init_command(): Initializing NAND devices...
  30. Debug: 103 12320 command.c:153 script_debug(): command - pld init
  31. Debug: 104 12320 pld.c:337 handle_pld_init_command(): Initializing PLDs...
  32. Debug: 105 12320 command.c:153 script_debug(): command - tpiu init
  33. Info : 106 12320 gdb_server.c:3936 gdb_target_start(): [riscv.tap.0] starting gdb server on 3333
  34. Info : 107 12320 server.c:298 add_service(): Listening on port 3333 for gdb connections
  35. Debug: 108 12320 command.c:153 script_debug(): command - target names
  36. Debug: 109 12320 command.c:153 script_debug(): command - target names
  37. Debug: 110 12320 command.c:153 script_debug(): command - riscv.tap.0 cget -type
  38. Debug: 111 12320 command.c:153 script_debug(): command - shutdown
  39. User : 112 12320 server.c:760 handle_shutdown_command(): shutdown command invoked
  40. Debug: 113 12320 breakpoints.c:319 breakpoint_remove_all_internal(): [riscv.tap.0] Delete all breakpoints
  41. Debug: 114 12320 riscv.c:511 riscv_deinit_target(): [riscv.tap.0] riscv_deinit_target()
  42. Error: 115 12320 riscv.c:437 get_target_type(): [riscv.tap.0] Unsupported DTM version: -1
  43. Error: 116 12320 riscv.c:516 riscv_deinit_target(): [riscv.tap.0] Could not identify target type.
  44. Debug: 117 12320 target.c:2136 target_free_all_working_areas_restore(): freeing all working areas
  45. Error: 118 12321 log.c:500 log_socket_error(): Error on socket 'remote_bitbang_putc': errno==32, message: Broken pipe.
  46. Error: 119 12321 adapter.c:191 adapter_quit(): failed: -4
  47. make: *** [Makefile:70: run_open] Broken pipe


复制代码
可以看到出现了“Listening on port 3333 for gdb connections”,但仿真已终止,Openocd 也因报错而终断运行了。
此外,提取 e203 内的 TAP 状态机波形,发现 TMS 和 TRST 都为低电平后,状态机卡在了 SHIFT_DR 状态。
3.png
究竟是什么原因导致 Openocd 无法正常监听 gdb 端口呢?
您的任何提示我都感激不尽!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条


小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-11-22 00:28 , Processed in 0.017116 second(s), 9 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表