Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Darjeeling #59

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3391311
[ot] hw/opentitan: ot_mbx: add a dedicated address space for RAM
rivos-eblot Mar 28, 2024
8fae94e
[ot] hw/riscv: ot_darjeeling.c: configure MBOX to use reserved MBOX SRAM
rivos-eblot Mar 28, 2024
909c40d
[ot] hw/misc: pulp_rv_dm.c: shorten Pulp DM memory region names
rivos-eblot Mar 28, 2024
6a5a7ef
[ot] hw/opentitan: ot_dev_proxy.c: rework device enumeration
rivos-eblot Mar 28, 2024
558fe6c
[ot] jtag: jtag_bitbang.c: add an option to manage remote VM termination
rivos-eblot Apr 3, 2024
4995bbe
[ot] hw/riscv: dm.c: command errors should not be propagated as DMI e…
rivos-eblot Apr 4, 2024
10305f2
[ot] hw/riscv: dm.c: add DM name to all trace messages
rivos-eblot Apr 2, 2024
f8b9202
[ot] hw/opentitan: dm.c: disable left-over debug trace
rivos-eblot Apr 2, 2024
1526657
[ot] hw/riscv: dm.c: simplify trace message masking
rivos-eblot Apr 3, 2024
ea79962
[ot] hw/riscv: dm.c: register on DTM on realization, not on reset.
rivos-eblot Apr 3, 2024
c818978
[ot] hw/riscv: dm.c: code cleanup, add a new trace
rivos-eblot Apr 4, 2024
558bdbb
[ot]: hw/riscv: OpenTitan RISC-V DM support abstractauto feature.
rivos-eblot Apr 4, 2024
b99e33b
[ot] docs/opentitan: add initial documentation for JTAG Debug Module
rivos-eblot Apr 5, 2024
d941d4d
[ot] scripts/opentitan: OpenOCD: update darjeeling config file
rivos-eblot Apr 2, 2024
590fcb9
[ot] hw/riscv: add a new API for IbexIRQ initialization.
rivos-eblot Mar 20, 2024
204434d
[ot] hw/opentitan: ot_pinmux: add IbexIRQs to manage pad config
rivos-eblot Mar 20, 2024
34c74bf
[ot] hw/opentitan: ot_pinmux: rework to support pinmux variants
rivos-eblot Mar 20, 2024
37f8d77
[ot] hw/opentitan: ot_gpio: implement I/O as IbexIRQs
rivos-eblot Mar 20, 2024
b4d3a29
[ot] hw/opentitan: ot_gpio: rework to support gpio variants
rivos-eblot Mar 21, 2024
8e9be80
[ot] hw/opentitan: remove useless header file inclusions
rivos-eblot Mar 20, 2024
dc1091a
[ot] hw/opentitan: ot_gpio_dj: add HW strap support
rivos-eblot Mar 21, 2024
519bb5f
[ot] hw/opentitan: ot_pwrmgr: add HW strap sampling
rivos-eblot Mar 21, 2024
61f1899
[ot] hw/riscv: ot_darjeeling: connect HW strap signal from PwrMgr to …
rivos-eblot Mar 21, 2024
55660ea
[ot] hw/opentitan: ot_gpio: add support for PinMux and GPIO output
rivos-eblot Mar 21, 2024
966330f
[ot] scripts/opentitan: update Treillis script with new GPIO features.
rivos-eblot Apr 5, 2024
35f940f
[ot] scripts/opentitan: add new gpiodev.py script to exercise GPIO
rivos-eblot Mar 22, 2024
3072007
[ot] hw/block: m25p80.c: implement Resettable API for SPI flash devices.
rivos-eblot Mar 26, 2024
c1d5ce7
[ot] hw/block: m25p80.c: add a "RESET#" input GPIO to manage HW reset
rivos-eblot Mar 26, 2024
3229806
[ot] hw/opentitan: dtm: add a sanity check for registering DMs
rivos-eblot Apr 8, 2024
f18c2ad
[ot] hw/opentitan: dm: register on DTM while resetting
rivos-eblot Apr 8, 2024
cce452a
[ot] hw/riscv: ot_darjeeling: fix DMI base address of RV DM
rivos-eblot Apr 8, 2024
4267bca
[ot] hw/opentitan: jtag_bitbang: use info_report rather than qemu_log
rivos-eblot Apr 8, 2024
d27e05f
[ot] scripts/opentitan: pyot.py: fix invalid execution time with ext.…
rivos-eblot Apr 8, 2024
4d9aca6
[ot] scripts/opentitan: pyot.py: improve & factorize log message reports
rivos-eblot Apr 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/opentitan/darjeeling.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Please check out `hw/opentitan/ot_ref.log`
* OTP controller
* read and write features are supported, Present scrambling is supported w/ digest checks,
ECC bits are ignored
* [RISC-V Debug Module](jtag-dm.md) and Pulp Debug Module
* SPI data flash (from QEMU upstream w/ fixes)
* SPI Host controller
* HW bus config is ignored (SPI mode, speed, ...)
Expand Down
16 changes: 11 additions & 5 deletions docs/opentitan/devproxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Only initiated by the application.
+---------------+---------------+---------------+---------------+
```

The current version for this documentation is v0.12.
The current version for this documentation is v0.13.

Note that semantic versionning does not apply for v0 series.

Expand Down Expand Up @@ -211,7 +211,7 @@ driven from the Application over the communication link.
+---------------+---------------+---------------+---------------+
|0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F|
+---------------+---------------+---------------+---------------+
| 'ed' | 0..4*4N |
| 'ed' | 0..4*7N |
+---------------+---------------+---------------+---------------+
| UID |0|
+---------------+---------------+---------------+---------------+
Expand All @@ -222,8 +222,10 @@ driven from the Application over the communication link.
| Word Count |
+---------------+---------------+---------------+---------------+
| |
| |
| Identifier |
| |
| |
+---------------+---------------+---------------+---------------+
| Offset | Device | - |
+---------------+---------------+---------------+---------------+
Expand All @@ -232,8 +234,10 @@ driven from the Application over the communication link.
| Word Count |
+---------------+---------------+---------------+---------------+
| |
| |
| Identifier |
| |
| |
+---------------+---------------+---------------+---------------+
| .... |
+---------------+---------------+---------------+---------------+
Expand All @@ -244,11 +248,13 @@ driven from the Application over the communication link.
| Word Count |
+---------------+---------------+---------------+---------------+
| |
| |
| Identifier |
| |
| |
+---------------+---------------+---------------+---------------+
```
Reponse contains 0 up to N devices, each device is described with a 20-byte entry, where:
Reponse contains 0 up to N devices, each device is described with a 28-byte entry, where:

* `Device` is a unique device identifier that should be used to select the device for all further
requests to the device.
Expand All @@ -258,7 +264,7 @@ Reponse contains 0 up to N devices, each device is described with a 20-byte entr
only if b0 is zero.
* `WordCount` is the count of 32-bit slots for a memory-type device
* `Base Address` is the base address of the device in the address space as seen from the local CPU.
* `Identifier` is an arbitrary 8-character string that describes the device.
* `Identifier` is an arbitrary 16-character string that describes the device.

The count of device entries can be retrieved from the `LENGTH` field.

Expand Down Expand Up @@ -338,7 +344,7 @@ Reponse contains 0 up to N devices, each device is described with a 28-byte entr
commands.
* `Start Address` is the lowest valid address in the address space.
* `Size` is the size (in bytes) of the address space
* `Identifier` is an arbitrary 16-character string that describes the device.
* `Identifier` is an arbitrary 16-character string that describes the memory space.

The count of address spaces can be retrieved from the `LENGTH` field.

Expand Down
40 changes: 32 additions & 8 deletions docs/opentitan/gpio.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
# OpenTitan GPIO

## Foreword

There are two variations of the GPIO device: one for EarlGrey, one for Darjeeling variants.

In the following document, `OTMACHINE` should be defined as `eg` for EarlGrey machine or as `dj`
for Darjeeling one.

## Initial configuration

It is possible to configure initial values of the GPIO input pins:
It is possible to configure initial values of the GPIO pins:

OpenTitan GPIO driver accept global options:

OpenTitan GPIO driver accept a global option:
- `ot-gpio-$OTMACHINE.in` defines the input values of the GPIO port as a 32-bit value
- `ot-gpio-$OTMACHINE.out` defines the output values of the GPIO port as a 32-bit value
- `ot-gpio-$OTMACHINE.oe` defines the output enable of the GPIO port as a 32-bit value

- `ot-gpio.in` that defines the input values of the GPIO port as a 32-bit value
All values default to zero, that is all GPIOs as input/hi-z, read 0.

### Example

```
-global ot-gpio.in=0x00ffff00
-global ot-gpio-dj.in=0x00ffff00 -global ot-gpio-dj.oe=0x1 -global ot-gpio-dj.out=0x1
```

Note: If there were several GPIO instances in a machine, these configurations would apply to all
GPIO instances.

## Character Device

OpenTitan GPIO driver can be connected to any CharDev device to expose as a very simple ASCII data
Expand All @@ -24,7 +38,7 @@ This CharDev device can be used to stimulate the GPIO and perform unit tests.
To connect the GPIO to its optional characted device, use the following QEMU option

```
-chardev type,id=gpio -global ot-gpio.chardev=gpio
-chardev type,id=gpio -global ot-gpio-$OTMACHINE.chardev=gpio
```

where type is one of the supported QEMU chardev type, such as
Expand Down Expand Up @@ -63,12 +77,17 @@ The hex value represents the 32-bit GPIO values.

A type describes the meaning of the hex value. Supported types are:

* `C` clear/reset host (at QEMU start up)
* `D` direction, _i.e._ Output Enable in OpenTitan terminology (QEMU -> host)
* `I` input GPIO values (host -> QEMU)
* `M` mask GPIO input values, i.e. non connected input pins (host -> QEMU)
* `O` output GPIO values (QEMU -> host)
* `P` output GPIO pull up/down values (QEMU -> host)
* `Q` query input (QEMU -> host). QEMU may emit this frame, so that the host replies with a new
`I` frame (hexvalue of `Q` is ignored)
input `I` frame (hexvalue of `Q` is ignored)
* `R` repeat (host -> QEMU). The host may ask QEMU to repeat the last `D` and `O` frames
* `Z` output pull up/down GPIO HiZ values (QEMU -> host). 1 means HiZ, 0 means
pull up/down values apply.

Frames are only emitted whenever the state of either peer (QEMU, host) change. QEMU should emit `D`
and `O` frames whenever the GPIO configuration or output values are updated. The host should emit
Expand All @@ -88,9 +107,14 @@ the QEMU machine over a serial port (a USB CDC VCP in this case).
To connect to the NeoTrellis board, use a configuration such as:

```
-chardev serial,id=gpio,path=/dev/ttyACM1 -global ot-gpio.chardev=gpio
-chardev serial,id=gpio,path=$SERIALDEV -global ot-gpio-$OTMACHINE.chardev=gpio
```

where /dev/ttyACM1 is the data serial port of the Neotreillis board.
where `SERIALDEV` is the data serial port of the Neotreillis board, _e.g._ `/dev/ttyACM1`

Note: the first serial port of the board is reserved to its debug console.

### Testing

See the [gpiodev.py](gpiodev.md) script.

78 changes: 78 additions & 0 deletions docs/opentitan/gpiodev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# `gpiodev.py`

`gpiodev.py` acts as a GPIO CharDev backend to record and verify GPIO updates.

It can be used to run regression tests and verify that the guest emits a predefined sequence of
GPIO updates.

## Usage

````text
usage: gpiodev.py [-h] [-p PORT] [-c CHECK] [-r RECORD] [-e END] [-q] [-s] [-t] [-v] [-d]

GPIO device tiny simulator.

options:
-h, --help show this help message and exit
-p PORT, --port PORT remote host TCP port (defaults to 8007)
-c CHECK, --check CHECK
input file to check command sequence
-r RECORD, --record RECORD
output file to record command sequence
-e END, --end END emit the specified value to trigger remote exit on last received command
-q, --quit-on-error exit on first error
-s, --single run once: terminate once first remote disconnects
-t, --log-time emit time in log messages
-v, --verbose increase verbosity
-d, --debug enable debug mode
````

### Arguments

* `-d` only useful to debug the script, reports any Python traceback to the standard error stream.

* `-p` specify an alternative TCP port to listen for incoming QEMU CharDev socket requests

* `-c` specify a pre-recorded GPIO backend text file - which only contains ASCII characters and
compare that incoming GPIO requests against the recorded data

* `-r` specify a file to record incoming GPIO requests

* `-e` emit a pre-defined GPIO input command - sent to the QEMU GPIO CharDev backend - that may be
recognized by the QEMU guest code as a special marker to end a test sequence. Requires the _check_
option for detecting the last expected GPIO request.

* `-q` close the QEMU socket connection on first error or mismatched GPIO request when used with
the _check_ option.

* `-s` quite the script on the first QEMU socket disconnection. Default is to listen for a new QEMU
CharDev socket connection, restarting from a fresh state.

* `-t` add time to log messages

* `-v` can be repeated to increase verbosity of the script, mostly for debug purpose.

### Exit Status

This script returns 0 if no error has been detected, or 1 if an error has been detected or the
GPIO command stream has not been validated against the check file if any.

### Examples

With the following examples:

`-chardev socket,id=gpio,host=localhost,port=8007 -global ot-gpio-$OTMACHINE.chardev=gpio` has been
added to the QEMU command line to connect the GPIO backend to the incoming socket opened from the
script. See the [GPIO documentation](gpio.md) for details and the role of the `OTMACHINE`
environment variable.

* Record a GPIO request sequence
````sh
./scripts/opentitan/gpiodev.py -vv -r gpio.txt -s
````

* Check a GPIO request sequence against a previously record one, then triggers a VM guest app
triggered termination by setting GPIO 31 to a high level.
````sh
./scripts/opentitan/gpiodev.py -vv -c gpio.txt -s -e 0x8000_0000
````
120 changes: 120 additions & 0 deletions docs/opentitan/jtag-dm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# JTAG and RISC-V Debug Module support for OpenTitan

RISC-V Debug Module is implemented as an alternative to the default QEMU GDB server.

It can be used when low-level features are required, such as prototyping JTAG manufacturing and
provisioning software development, or emulating JTAG Debug Authentication.

This initial implementation of the RISC-V Debug Module and Pulp DM supports the following features:

- Ibex core debugging (RV32 only); not tested with multiple harts
- system bus memory access: read and write guest memory
- guest code debugging
- single stepping
- HW breakpoints
- HW watchpoints

## Communicating with RISC-V DM through a JTAG connection

In QEMU machines for OpenTitan, any Debug Module can register on the Debug Transport Module, which
dispatches requests to Debug Module depending on the received DMI address.

See also [JTAG mailbox](jtagmbx.md) and [Life Controller](lc_ctrl_dmi.md) for other Debug Modules.

```
+----------------+
| Host (OpenOCD) |
+----------------+
|
| TCP connection ("bitbang mode")
|
+-----|-----------------------------------------------------------------------------------+
| | QEMU |
| v +---------+ |
| +-------------+ +-----+ +-----------+ | PULP-DM | +------+ |
| | JTAG server |---->| DTM |---->| RISC-V DM |<---->+ ------- +<=======>| Hart | |
| +-------------+ +-----+ +-----------+ | ROM/RAM | || +------+ |
| || +---------+ || |
| || || +--------------+ |
| ================================>| I/O, RAM, ...| |
| +--------------+ |
+-----------------------------------------------------------------------------------------+
```

### Remote bitbang protocol

The JTAG server supports the Remote Bitbang Protocol which is compatible with other tools such as
Spike and [OpenOCD](https://github.com/riscv/riscv-openocd).

QEMU should be started with an option such as `-jtag tcp::3335` so that the JTAG server is
instantiated and listens for incoming connection on TCP port 3335.

#### Remote termination feature

The remote Remote Bitbang Protocol supports a "_quit_" feature which enables the remote client to
trigger the end of execution of the QEMU VM. This feature can be useful to run automated tests for
example.

It is nevertheless possible to disable this feature and ignore the remote exit request so that
multiple JTAG sessions can be run without terminating the QEMU VM.

To disable this feature, use the `quit` option: `-jtag tcp::3335,quit=off`.

#### macOS

If you want to avoid the boring pop-up window from macOS
```
Do you want the application “qemu-system-riscv32” to accept incoming network connections?
```
restrict the listening interfaces to the localhost with `-jtag tcp:localhost:3335` as QEMU defaults
to listening on all interfaces, _i.e._ 0.0.0.0

#### Implementation

* JTAG server is implemented with `jtag/jtag_bitbang.c`
* DTM is implemented with `hw/riscv/dtm.c`
* RISC-V DM is implemented with `hw/riscv/dm.c`
* Pulp-DM is implemented with `hw/misc/pulp_rv_dm.c`

See also other supported DM modules on OpenTitan:

* [JTAG mailbox DMI](jtagmbx.md)
* [LifeCycle DMI](lc_ctrl_dmi.md)

## Communicating with JTAG server using OpenOCD

OpenOCD running on a host can connect to the embedded JTAG server, using a configuration script such
as

```tcl
adapter driver remote_bitbang
remote_bitbang host localhost
remote_bitbang port 3335

transport select jtag

set _CHIPNAME riscv
# part 1, ver 0, lowRISC; actual TAP id depends on the QEMU machine
set _CPUTAPID 0x00011cdf

jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id $_CPUTAPID

# Hart debug base also depends on the QEMU machine
set DM_BASE 0x00

target create $_CHIPNAME riscv -chain-position $_TARGETNAME rtos hwthread -dbgbase $DM_BASE
```

## Connecting GDB to OpenOCD

In another terminal, `riscv{32,64}-unknown-elf-gdb` can be used to connect to OpenOCD:

```
# 64-bit version support 32-bit targets
riscv64-unknown-elf-gdb
```

A basic `$HOME/.gdbinit` as the following should connect GDB to the running OpenOCD instance:
```
target remote :3333
```
6 changes: 3 additions & 3 deletions docs/opentitan/jtagmbx.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ system side (requester) is connected to a Debug Tile Link bus.

## Communicating with the JTAG Mailbox through a JTAG connection

In QEMU, a bridge between the Debug Module Interface (DMI) and the JTAG Mailbox is implemented
In QEMU, a bridge between the Debug Transport Module (DTM) and the JTAG Mailbox is implemented
as Debug Module bridge.

```
Expand All @@ -18,7 +18,7 @@ as Debug Module bridge.
+-----|-----------------------------------------------------------------------------------+
| v |
| +-------------+ +-----+ +----------+ +---------+ +------+ |
| | JTAG server |---->| DMI |---->| ot_dm_tl |====D====|S> MBX <H|====P====| Hart | |
| | JTAG server |---->| DTM |---->| ot_dm_tl |====D====|S> MBX <H|====P====| Hart | |
| +-------------+ +-----+ +----------+ +---------+ +------+ |
| QEMU|
+-----------------------------------------------------------------------------------------+
Expand Down Expand Up @@ -136,7 +136,7 @@ no RISC-V DM module is connected to the DMI device, _i.e._
+-----|-----------------------------------------------------------------------------------+
| v |
| +-------------+ +-----+ +----------+ +---------+ +------+ |
| | JTAG server |---->| DMI |-+-->| ot_dm_tl |====D====|S> MBX <H|===++=P==| Hart | |
| | JTAG server |---->| DTM |-+-->| ot_dm_tl |====D====|S> MBX <H|===++=P==| Hart | |
| +-------------+ +-----+ | +----------+ +---------+ || +------+ |
| | || |
| | +----+ +-------- + || |
Expand Down
Loading
Loading