You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
microwatt/scripts/mw_debug
Paul Mackerras 49a4d9f67a Add core logging
This logs 256 bits of data per cycle to a ring buffer in BRAM.  The
data collected can be read out through 2 new SPRs or through the
debug interface.

The new SPRs are LOG_ADDR (724) and LOG_DATA (725).  LOG_ADDR contains
the buffer write pointer in the upper 32 bits (in units of entries,
i.e. 32 bytes) and the read pointer in the lower 32 bits (in units of
doublewords, i.e. 8 bytes).  Reading LOG_DATA gives the doubleword
from the buffer at the read pointer and increments the read pointer.
Setting bit 31 of LOG_ADDR inhibits the trace log system from writing
to the log buffer, so the contents are stable and can be read.

There are two new debug addresses which function similarly to the
LOG_ADDR and LOG_DATA SPRs.  The log is frozen while either or both of
the LOG_ADDR SPR bit 31 or the debug LOG_ADDR register bit 31 are set.

The buffer defaults to 2048 entries, i.e. 64kB.  The size is set by
the LOG_LENGTH generic on the core_debug module.  Software can
determine the length of the buffer because the length is ORed into the
buffer write pointer in the upper 32 bits of LOG_ADDR.  Hence the
length of the buffer can be calculated as 1 << (31 - clz(LOG_ADDR)).

There is a program to format the log entries in a somewhat readable
fashion in scripts/fmt_log/fmt_log.c.  The log_entry struct in that
file describes the layout of the bits in the log entries.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years ago
..
Makefile mw_debug: Add README 4 years ago
README mw_debug: Add README 4 years ago
mw_debug.c Add core logging 4 years ago

README

mw_debug is the microwatt debugger.

It can talk to the simulator using a socket.

On an Arty board it uses the FTDI device via liburjtag.

## Building on Fedora

```
dnf install urjtag-devel
make
```

If you commonly use it against one target, create an alias as follows:
```
alias mw="$HOME/microwatt/scripts/mw_debug/mw_debug -b jtag"
$ mw gpr 0 10
Connected to libftdi driver.
Found device ID: 0x0362d093
r0:	0000000000001094
r1:	0000000000001ed0
r2:	000000000000a000
r3:	0000000000000003
r4:	000000000000000d
r5:	00000000ffff2ca5
r6:	00000000ffff3eb8
r7:	0000000000000000
r8:	00000000ffff3c33
r9:	0000000000000003
Core: running
 NIA: 00000000000011d4
 MSR: 8000000000000001
```

## Building on Debian

Debian disables the library in the urjtag package. Instead, build against
local urjtag:

```
sudo apt install libftdi-dev
git clone https://git.code.sf.net/p/urjtag/git urjtag
cd urjtag/urjtag
./autogen.sh
make
```

And then uncomment the following line in Makefile to build against that copy

```
CFLAGS +=  -I urjtag/urjtag/include/ -L urjtag/urjtag/src/.libs/
```

To run:
```
alias mw="LD_LIBRARY_PATH=$HOME/microwatt/scripts/mw_debug/urjtag/urjtag/src/.libs/ $HOME/microwatt/scripts/mw_debug/mw_debug -b jtag"
$ mw
Connected to libftdi driver.
Found device ID: 0x0362d093
Core: running
 NIA: 00000000000011b8
 MSR: 8000000000000001
```