gdb - 用 riscV-gdb 连接到自制的 openOCD
问题描述
以下连接尝试失败。reiscV-gdb -> patched openOCD
(见下面的设置)。以下消息显示在 gdb 和 openOCD 中
riscV-gdb 输出
(gdb) target remote 127.0.0.1:3333
Remote debugging using 127.0.0.1:3333
warning: Architecture rejected target-supplied description
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
Truncated register 22 in remote 'g' packet
上述尝试的 openOCD 调试输出
Info : 543 2761051 server.c:100 add_connection(): accepting 'gdb' connection on tcp/3333
Debug: 544 2761052 breakpoints.c:354 breakpoint_clear_target_internal(): Delete all breakpoints for target: myOwnCPU.cpu
Debug: 545 2761052 breakpoints.c:494 watchpoint_clear_target(): Delete all watchpoints for target: myOwnCPU.cpu
Debug: 546 2761052 target.c:1581 target_call_event_callbacks(): target event 19 (gdb-attach)
Debug: 547 2761052 target.c:4535 target_handle_event(): target(0): myOwnCPU.cpu (myOwnCPU) event: 19 (gdb-attach) action: halt
Debug: 548 2761053 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_halt
Debug: 549 2761055 command.c:143 script_debug(): command - halt ocd_halt
Debug: 551 2761057 target.c:3018 handle_halt_command(): -
Debug: 570 2761060 gdb_server.c:1014 gdb_new_connection(): New GDB Connection: 1, Target myOwnCPU.cpu, state: halted
Debug: 571 2761060 gdb_server.c:3160 gdb_input_inner(): received packet: 'qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386'
Debug: 575 2761061 gdb_server.c:3160 gdb_input_inner(): received packet: 'vMustReplyEmpty'
Debug: 576 2761061 gdb_server.c:3160 gdb_input_inner(): received packet: 'QStartNoAckMode'
Debug: 577 2761061 gdb_server.c:639 gdb_get_packet_inner(): Received first acknowledgment after entering noack mode. Ignoring it.
Debug: 578 2761061 gdb_server.c:3160 gdb_input_inner(): received packet: 'Hg0'
Debug: 579 2761062 gdb_server.c:3160 gdb_input_inner(): received packet: 'qXfer:features:read:target.xml:0,1000'
Debug: 583 2761072 gdb_server.c:3160 gdb_input_inner(): received packet: 'qXfer:features:read:target.xml:1000,1000'
Debug: 584 2761073 gdb_server.c:3160 gdb_input_inner(): received packet: 'qXfer:features:read:target.xml:2000,1000'
Debug: 585 2761073 gdb_server.c:3160 gdb_input_inner(): received packet: 'qXfer:features:read:target.xml:3000,1000'
Debug: 586 2761074 gdb_server.c:3160 gdb_input_inner(): received packet: 'qXfer:features:read:target.xml:4000,1000'
Debug: 587 2761074 gdb_server.c:3160 gdb_input_inner(): received packet: 'qXfer:features:read:target.xml:5000,1000'
Debug: 588 2761077 gdb_server.c:3160 gdb_input_inner(): received packet: 'qTStatus'
Debug: 589 2761077 gdb_server.c:3160 gdb_input_inner(): received packet: '?'
Debug: 590 2761077 gdb_server.c:3160 gdb_input_inner(): received packet: 'qXfer:threads:read::0,1000'
Debug: 591 2761077 gdb_server.c:3160 gdb_input_inner(): received packet: 'Hc-1'
Debug: 592 2761078 gdb_server.c:3160 gdb_input_inner(): received packet: 'qC'
Debug: 593 2761078 gdb_server.c:3160 gdb_input_inner(): received packet: 'qAttached'
Debug: 594 2761078 gdb_server.c:3160 gdb_input_inner(): received packet: 'g'
Debug: 598 2761096 gdb_server.c:1046 gdb_connection_closed(): GDB Close, Target: myOwnCPU.cpu, state: halted, gdb_actual_connections=0
Debug: 599 2761096 target.c:1581 target_call_event_callbacks(): target event 6 (gdb-end)
Debug: 600 2761096 target.c:1581 target_call_event_callbacks(): target event 20 (gdb-detach)
Info : 601 2761096 server.c:577 server_loop(): dropped 'gdb' connection
- 我不知道为什么连接断开
- 我想我需要在我的
target.get_gdb_reg_list()
- 或者我在我的
target.get_gdb_reg_list()
- 我需要知道必须提供哪些信息才能使 riscV-gdb 接受来自 openOCD 的连接(充当 gdb-server)。
设置:
原始 riscv-gdb
来自 masterbranch 的 openOCD
- 添加了对新 TAP-Controller 的支持(错误部分)
- 链:jtag(基于 ftdi)--“新 TAP”--“riscV(零风险)”
附录:
与普通 gdb (7.11.1) 连接通常可以:
(gdb) target remote 127.0.0.1:3333
Remote debugging using 127.0.0.1:3333
warning: Architecture rejected target-supplied description
0x000041b8 in ?? ()
我可以启动/停止 cpu,加载图像等。我的注册视图看起来像
(gdb) info registers
eax 0x0 0
ecx 0x88aa 34986
edx 0x6fc4 28612
ebx 0x0 0
esp 0x0 0x0
ebp 0x0 0x0
esi 0x850 2128
edi 0x0 0
eip 0x41b8 0x41b8
eflags 0x0 [ ]
cs 0x40e4 16612
ss 0x4 4
ds 0xffffffff -1
es 0x7f7f7f7f 2139062143
fs 0xa00 2560
gs 0x0 0
应该有更多的寄存器。x00 到 x31 + 几个配置寄存器。程序计数器正确。
解决方案
从上面谷歌搜索一些错误消息只会得出结论......错误的GDB。但是我已经使用默认选项从 riscv-repository 编译了 GDB。这根本没有帮助......
以下 w2 为线索!
# cd into your destination folder and invoke a git clone of the riscV-OpenOCD
git clone https://github.com/riscv/riscv-binutils-gdb.git
# build gdb with riscv-support
mkdir build
cd build
../riscv-binutils-gdb/configure --prefix=${GDB_INSTALL_FOLDER} \
--target=riscv-elf --program-prefix=riscv-elf-
# build
make all
# move build files into predefined install folder
make install
# to room up after build
# make distclean
--target=riscv-elf
是您想要的选项。GDB 需要一组特定的寄存器。由于这是原始存储库的克隆,因此默认值为 i386。它还期望来自这样的 cpu 的寄存器定义和功能。
要检查 gdb 支持的架构,请运行:(gdb) set architecture
不带参数。对于我的零风险,我必须选择(gdb) set architecture riscv:rv32
. 之后我冷连接到目标而不会丢失连接。
推荐阅读
- c# - 在 ASP.NET Core Web API 项目中保持控制器温暖
- parallel-processing - 设置计算单元 (CPU) 的数量
- .net - JSON_QUERY(@data, '$') 仅从 JSON 中获取第一个元素
- visual-studio - 在 Visual Studio 中工作时传递 ./configure 标志
- python - 计算 DataFrame 列中的字数
- android - 如何从geoacast json中获取纬度和经度值
- tableau-api - 带有画面的文档数据库
- performance - URL 是请求大小的一部分吗?
- python - 在保持变量的同时更改 Pandas 中的字符串
- python - 使用 Mac OS 通过 pip install 安装 sklearn 失败