Question about debugging by GDB on Hifive1

Hi all!
I have a problem about debuging by GDB.I have tried some methods explained there and still the same problem. What i have done shown as below.
open a screen window:
screen /dev/ttyUSB1 115200

run openocd and GDB on a window(by the way, i also tried open them on differnt window, and the same problem)
make run_debug PROGRAM=mytest

the message shown on the GDB window:


Open On-Chip Debugger 0.10.0-dev-g9bab078 (2017-03-31-16:32)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
Info : auto-selecting first available session transport “jtag”. To override use 'transport select '.
GNU gdb (GDB) 7.12.50.20170109-git
Copyright © 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and “show warranty” for details.
This GDB was configured as “–host=x86_64-pc-linux-gnu --target=riscv32-unknown-elf”.
Type “show configuration” for configuration details.
For bug reporting instructions, please see:
<://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<://www.gnu.org/software/gdb/documentation/>.
For help, type “help”.
Type “apropos word” to search for commands related to “word”…
Reading symbols from /home/chris/HiFive/freedom-e-sdk/software/mytest/mytest…done.
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 10000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x10e31913 (mfg: 0x489 (), part: 0x0e31, ver: 0x1)
Info : Examined RISCV core; XLEN=32, misa=0x40001105
riscv.cpu: target state: halted
halted at 0x20405c68 due to debug interrupt
Remote debugging using localhost:3333
Info : accepting ‘gdb’ connection on tcp/3333
Info : Found flash device ‘issi is25lp128’ (ID 0x0018609d)
0x20405c68 in ?? ()


And, after a while,there is always a warning shown on the GDB window:


Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (5105). Workaround: increase “set remotetimeout” in GDB
keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (5105). Workaround: increase “set remotetimeout” in GDB


Then, i set a breakpoint on main function and run, it shows:


(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/chris/HiFive/freedom-e-sdk/software/mytest/mytest
Info : JTAG tap: riscv.cpu tap/device found: 0x10e31913 (mfg: 0x489 (), part: 0x0e31, ver: 0x1)
riscv.cpu: target state: halted
halted at 0x404 due to software breakpoint


The message shown on the screen window:


trap

Progam has exited with code:0x00000003


Any recomendation is welcome!

Thanks!

1 Like

You wrote;

(gdb) run

Your program may run already.

(gdb) target extended-remote localhost:3333
(gdb) b main   # set breakpoint at main()
(gdb) j _start # restart from the start-up routine

works for me.

I hope this helps.

I don’t know the run command works on this SDK or not. It does not work for me.

1 Like

Yes, I don’t usually use the run command, because we’re connecting to hardware that is already running. We can look into what GDB actually does with the run command and see how it translates to OpenOCD.

@chriszhang you may also want to refer to this other thread :

1 Like

Hi Sflin,
It works, thanks for your help. The run command doesn’t work for me too.

It works. Thanks for your reply.