Closed sebastien-riou closed 3 years ago
Hi,
I guess the issue is that the openocd port do not implement CSR register access. The hardware should be able to support it, as you can push instruction.
Else, another possibility is that the CPU configuration that you use do not implement reading mtvec via csr reads ?
looks like GDB issue, openocd+telnet read it just fine, sorry I close it.
1 > telnet localhost 4444
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> targets
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* saxon.cpu0 vexriscv little SOC_CPU.bridge halted
1 soc.sstap testee little SOC_SSTAP.bridge unknown
2 subsys.cpu0 vexriscv little SUBSYS_CPU.bridge halted
3 subsys.sstap testee little SUBSYS_SSTAP.bridge unknown
> reg pc
pc (/32): 0x20A00000
> reg mtvec
mtvec (/32): 0x00000000
> resume
> targets
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* saxon.cpu0 vexriscv little SOC_CPU.bridge running
1 soc.sstap testee little SOC_SSTAP.bridge unknown
2 subsys.cpu0 vexriscv little SUBSYS_CPU.bridge halted
3 subsys.sstap testee little SUBSYS_SSTAP.bridge unknown
> reg mtvec
mtvec (/32): 0x20A01278
> targets
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* saxon.cpu0 vexriscv little SOC_CPU.bridge running
1 soc.sstap testee little SOC_SSTAP.bridge unknown
2 subsys.cpu0 vexriscv little SUBSYS_CPU.bridge halted
3 subsys.sstap testee little SUBSYS_SSTAP.bridge unknown
accepting 'gdb' connection on tcp/3333
New GDB Connection: 1, Target saxon.cpu0, state: halted
> targets
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* saxon.cpu0 vexriscv little SOC_CPU.bridge halted
1 soc.sstap testee little SOC_SSTAP.bridge unknown
2 subsys.cpu0 vexriscv little SUBSYS_CPU.bridge halted
3 subsys.sstap testee little SUBSYS_SSTAP.bridge unknown
> reg mtvec
mtvec (/32): 0x20A01278
>
GDB:
GNU gdb (SiFive GDB-Metal 10.1.0-2020.12.7) 10.1
Copyright (C) 2020 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-linux-gnu --target=riscv64-unknown-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://github.com/sifive/freedom-tools/issues>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from build/SaxonSubsys/tiempo_bootloader.elf...
(gdb) set remotetimeout 10000
(gdb) set arch riscv:rv32
The target architecture is set to "riscv:rv32".
(gdb) target extended-remote :3333
Remote debugging using :3333
0x20a02538 in ?? ()
(gdb) info registers $pc
pc 0x20a02538 0x20a02538
(gdb) info registers $mtvec
mtvec 0x0 0
(gdb) info registers $mtvec
mtvec 0x0 0
(gdb) info registers $mtvec
mtvec 0x0 0
(gdb) stepi
0x20a0253a in ?? ()
(gdb) info registers $mtvec
mtvec 0x20a01278 547361400
Not sure if the issue is hardware or software. The first read via GDB returns a wrong value (always the same across multiple trials on FPGA). I get the correct value after a stepi (with an instruction which does not touch mtvec).