SpinalHDL / openocd_riscv

Spen's Official OpenOCD Mirror
Other
47 stars 34 forks source link

Error: target 'fpga_spinal.cpu0' init failed #34

Open ottotto335 opened 1 year ago

ottotto335 commented 1 year ago

Open On-Chip Debugger 0.11.0+dev-04033-g058dfa50d (2023-02-20-09:48) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html /home/wjc/Desktop/VexRiscv_old/cpu0.yaml DEPRECATED! use 'adapter driver' not 'interface' Info : only one transport option; autoselect 'jtag' DEPRECATED! use 'adapter speed' not 'adapter_khz' DEPRECATED! use 'adapter srst delay' not 'adapter_nsrst_delay' Info : set servers polling period to 50ms Error: target 'fpga_spinal.cpu0' init failed

I try to use eclipse to debug the project "Vexriscv.demo.GenFull" , and set the configuration like https://drive.google.com/open?id=1c46tyEV0xLwOsk76b0y2qqs8CYy7Zq3f, what's wrong with it?

Dolu1990 commented 1 year ago

Hi, what command are you using to run openocd ? which SoC are you targeting, on real hardware ?

ottotto335 commented 1 year ago

-c "set VEXRISCV_YAML /home/vexriscv/Desktop/VexRiscv_old/cpu0.yaml" -f /home/vexriscv/Desktop/openocd_riscv/tcl/target/vexriscv_sim.cfg i want to use verilator,what should I do?

Dolu1990 commented 1 year ago

Are you targeting a simulation ? or real hardware via usb jtag ?

ottotto335 commented 1 year ago

yes i'm targeting a simulation

Dolu1990 commented 1 year ago

Ahhh ok, which simulation testbench are you running exactly ?

ottotto335 commented 1 year ago

In the VexRiscv repository, to run the simulation on which one OpenOCD can connect itself =>

sbt "runMain vexriscv.demo.GenFull" cd src/test/cpp/regression make run DEBUG_PLUGIN_EXTERNAL=yes

In the openocd git, after building it =>

src/openocd -c "set VEXRISCV_YAML PATH_TO_THE_GENERATED_CPU0_YAML_FILE" -f tcl/target/vexriscv_sim.cfg

Run a GDB session with an elf RISCV executable (GenFull CPU)

YourRiscvToolsPath/bin/riscv32-unknown-elf-gdb VexRiscvRepo/src/test/resources/elf/uart.elf target remote localhost:3333 monitor reset halt load continue

I just follow this example in eclipse, using sbt in terminal to make the "cpu0.yaml" , then set up the configuration in eclipse with the rest of these commands

Dolu1990 commented 1 year ago

Hmm, did you used a absolute path for the """PATH_TO_THE_GENERATED_CPU0_YAML_FILE""" ?

ottotto335 commented 1 year ago

yes I replace it with the path on my pc, it's /home/591867/Desktop/VexRiscv/cpu0.yaml

Dolu1990 commented 1 year ago

So, i just tried on my side using your commands, and it seems fine. Here is the openocd logs when i run it :

Open On-Chip Debugger 0.11.0+dev-02583-g9d50e3c2f-dirty (2022-10-27-11:30)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
....VexRiscv/cpu0.yaml
DEPRECATED! use 'adapter driver' not 'interface'
Info : only one transport option; autoselect 'jtag'
DEPRECATED! use 'adapter speed' not 'adapter_khz'
DEPRECATED! use 'adapter srst delay' not 'adapter_nsrst_delay'
Info : set servers polling period to 50ms
Info : clock speed 4000 kHz
Info : TAP fpga_spinal.bridge does not have valid IDCODE (idcode=0x0)
Info : TAP auto0.tap does not have valid IDCODE (idcode=0x80000000)
Info : TAP auto1.tap does not have valid IDCODE (idcode=0xc0000000)
Info : TAP auto2.tap does not have valid IDCODE (idcode=0xe0000000)
Info : TAP auto3.tap does not have valid IDCODE (idcode=0xf0000000)
Info : TAP auto4.tap does not have valid IDCODE (idcode=0xf8000000)
Info : TAP auto5.tap does not have valid IDCODE (idcode=0xfc000000)
Info : TAP auto6.tap does not have valid IDCODE (idcode=0xfe000000)
Info : TAP auto7.tap does not have valid IDCODE (idcode=0xff000000)
Info : TAP auto8.tap does not have valid IDCODE (idcode=0xff800000)
Info : TAP auto9.tap does not have valid IDCODE (idcode=0xffc00000)
Info : TAP auto10.tap does not have valid IDCODE (idcode=0xffe00000)
Info : TAP auto11.tap does not have valid IDCODE (idcode=0xfff00000)
Info : TAP auto12.tap does not have valid IDCODE (idcode=0xfff80000)
Info : TAP auto13.tap does not have valid IDCODE (idcode=0xfffc0000)
Info : TAP auto14.tap does not have valid IDCODE (idcode=0xfffe0000)
Info : TAP auto15.tap does not have valid IDCODE (idcode=0xffff0000)
Info : TAP auto16.tap does not have valid IDCODE (idcode=0xffff8000)
Info : TAP auto17.tap does not have valid IDCODE (idcode=0xffffc000)
Info : TAP auto18.tap does not have valid IDCODE (idcode=0xffffe000)
Info : TAP auto19.tap does not have valid IDCODE (idcode=0xfffff000)
Warn : Unexpected idcode after end of chain: 21 0xfffff800
Error: double-check your JTAG setup (interface, speed, ...)
Error: Trying to use configured scan chain anyway...
Error: fpga_spinal.bridge: IR capture error; saw 0x0f not 0x01
Warn : Bypassing JTAG setup events due to errors
[fpga_spinal.cpu0] Target successfully examined.
Info : starting gdb server for fpga_spinal.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
requesting target halt and executing a soft reset
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : accepting 'telnet' connection on tcp/4444

I can then connect via telnet on it and do stuff.

You keept the "make run DEBUG_PLUGIN_EXTERNAL=yes" command runnig while you run openocd in another terminal ? (for now, don't add eclipse in the mix ^^)

ottotto335 commented 1 year ago

emmm I can also do this in terminal on my pc, but I'm asked to debug the project with eclipse . so actually I'm following this part ->"Using Eclipse to run and debug the software", and it isn't that clear, so could you please tell me how to set the configuartion in eclipse to run it?

Dolu1990 commented 1 year ago

Ahhh nice, that's already a good step. So if you get

Open On-Chip Debugger 0.11.0+dev-04033-g058dfa50d (2023-02-20-09:48)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
/home/wjc/Desktop/VexRiscv_old/cpu0.yaml
DEPRECATED! use 'adapter driver' not 'interface'
Info : only one transport option; autoselect 'jtag'
DEPRECATED! use 'adapter speed' not 'adapter_khz'
DEPRECATED! use 'adapter srst delay' not 'adapter_nsrst_delay'
Info : set servers polling period to 50ms
Error: target 'fpga_spinal.cpu0' init failed

It it maybe because you ran openocd twice ? once in the background, once with eclipse itself ? Personnaly, i'm not using eclipse to run openocd, i just let openocd run in the backgroud

ottotto335 commented 1 year ago

so I should let openocd run in the backgroud,and just use eclipse to run gdb? Then where should I print this command "make run DEBUG_PLUGIN_EXTERNAL=yes"? In another terminal or builder setting in eclipse?

Dolu1990 commented 1 year ago

so I should let openocd run in the backgroud,and just use eclipse to run gdb?

That's the way i'm doing it yes.

Then where should I print this command "make run DEBUG_PLUGIN_EXTERNAL=yes"? In another terminal or builder setting in eclipse?

Another terminal ^^

ottotto335 commented 1 year ago

oh I see, thanks a lot!^^ one last question,when I run gdb in eclipse, where should I print the path of .elf file in this command -> YourRiscvToolsPath/bin/riscv32-unknown-elf-gdb VexRiscvRepo/src/test/resources/elf/uart.elf in Run->Debug Configurations->GDB OpenOCD Debugging->Debugger->GDB client Setup->other options I guess?

Dolu1990 commented 1 year ago

ahhh to provide the elf to eclipse run configuration : image

ottotto335 commented 1 year ago

ok get it ! that's all, thanks for your help!^