与riscV-gdb连接到自制的openOCD

时间:2019-02-22 11:07:14

标签: gdb riscv

以下连接尝试失败。 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 +几个配置寄存器。程序计数器正确。

1 个答案:

答案 0 :(得分:0)

谷歌搜索一些错误消息只会导致结论……错误的GDB。但是我已经使用默认选项从riscv-reposetory编译了GDB。这根本没有帮助...

以下是线索!

# 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。之后,我不丢失连接就冷连接到目标。