Reputation: 3559
Following connection attempt fails. reiscV-gdb -> patched openOCD
(see setup below). Following messages are displayed in gdb and openOCD
(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
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()
original riscv-gdb
openOCD from masterbranch
connecting with the normal gdb (7.11.1) works in general:
(gdb) target remote 127.0.0.1:3333
Remote debugging using 127.0.0.1:3333
warning: Architecture rejected target-supplied description
0x000041b8 in ?? ()
I can start/stop the cpu, load images etc. My register view looks like
(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
There should be much more registers. x00 to x31 + a couple of config registers. The program counter is correct.
Upvotes: 1
Views: 1320
Reputation: 3559
Googling some error-messages from above leads to only on conclusion... Wrong GDB. But I've compiled the GDB from the riscv-repository with default options. This was not helping at all...
The following w2as the clue!
# 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
is the option you want. GDB expects a specific set of registers. As this is a clone from the original repository, the default is i386. It's also expecting registers definition and features from such a cpu.
To check the architecture your gdb supports run: (gdb) set architecture
with no arguments. For my zero riscy from pulpino I had to select (gdb) set architecture riscv:rv32
. Afterwards I cold connect to the target without loosing the connection.
Upvotes: 1