enjoy-digital / litex

Build your hardware, easily!
Other
2.98k stars 565 forks source link

OpenOCD cannot communicate with Vexriscv CPU #1628

Open donn opened 1 year ago

donn commented 1 year ago

I'm following this guide: https://github.com/enjoy-digital/litex/wiki/Use-GDB-with-VexRiscv-CPU

However, after starting litex_server and OpenOCD (litex_server --uart --uart-port=/dev/ttyACM0 --bind-port=1234), OpenOCD fails to connect to the CPU. Initially it was just quitting altogether with the same issue as https://github.com/enjoy-digital/litex/issues/1532: I applied the workaround in the issue, but then ran into another issue:

Open On-Chip Debugger 0.11.0+dev-04033-g058dfa50d-dirty (2023-03-01-20:29)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'adapter driver' not 'interface'
Info : only one transport option; autoselect 'jtag'
DEPRECATED! use 'adapter speed' not 'adapter_khz'
adapter speed: 1 kHz

4027514880
Info : clock speed 1 kHz
Info : TAP lx.cpu 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: lx.cpu: IR capture error; saw 0x0f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Warn : target lx.cpu0 examination failed
Info : starting gdb server for lx.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: lx.cpu: IR capture error; saw 0x0f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Error: !!!
Error: Can't communicate with the CPU
Error: !!!
Error: !!!
Error: Can't communicate with the CPU
Error: !!!

Here's how I generate my gateware, for reference:

import sys
import functools

from litex.soc.integration.builder import Builder
from litex.soc.integration.common import get_mem_data

# -- Board-Specific
import litex_boards.targets.gsd_orangecrab

make_board = functools.partial(
    litex_boards.targets.gsd_orangecrab.BaseSoC, device="85F"
)
# --

software = "software" in sys.argv
gateware = "gateware" in sys.argv

soc = make_board(
    cpu_name="vexriscv",
    cpu_variant="standard+debug",
    l2_size=8192,
    bus_standard="wishbone",
    bus_data_width=32,
    bus_address_width=32,
    bus_timeout=1e6,
    bus_bursting=False,
    bus_interconnect="shared",
    integrated_rom_size=131072,
    integrated_sram_size=8192,
    csr_data_width=32,
    csr_address_width=14,
    csr_paging=2048,
    csr_ordering="big",
    with_uart=True,
    uart_name="crossover+uartbone",
    uart_baudrate=115200,
    uart_fifo_depth=16,
    with_timer=True,
    timer_uptime=False,
    ident_version=True,
    with_ctrl=True,
)

builder = Builder(soc, compile_software=software, compile_gateware=gateware)
builder.build()
Dolu1990 commented 1 year ago

Info : TAP lx.cpu 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

That seems to indicate that you have an issue at the JTAG level, VexRiscv itself not being involved yet

Can you probe the jtag ?

donn commented 1 year ago

Will have to borrow a JTAG programmer, but I'll see what I can do.

I should mention though this particular series of messages is also in the guide, so I thought they were "expected."

donn commented 1 year ago

Colleague just tried with an Arty A7- curiously, when programming with Digilent Adept, OpenOCD connects fine, but if programming with OpenOCD it just hangs.

Dolu1990 commented 1 year ago

Ahhh my bad, i were assuming it was using jtag XD Sorry. Don't know so much about it

So the Error: !!! Error: Can't communicate with the CPU Error: !!!

Are some checks which are done when openocd VexRiscv connect to be sure the system is alive.

Hmm not sure how i can help as i don't realy know that flow with the litex_server