Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
18e0095
[ot] python/qemu/ot: do not repeat information for multiple proxy in…
rivos-eblot Oct 31, 2024
f4f65e7
[ot] hw/opentitan: ot_dma: add a property to define the DMA transfer …
rivos-eblot Nov 7, 2024
2747216
[ot] hw/opentitan: ot_dma: add a property to define the DMA pace delay.
rivos-eblot Nov 7, 2024
bef1425
[ot] hw/opentitan: ot_spi_host: do not refill RX FIFO on each RXDATA …
rivos-eblot Nov 7, 2024
550332c
[ot] hw/opentitan: ot_spi_host: rework SPI event management
rivos-eblot Nov 27, 2024
a4ebcfa
[ot] hw/opentitan: ot_spi_host: add a SPI command state.
rivos-eblot Dec 2, 2024
46687fb
[ot] scripts/opentitan: spiflashpat.py: add a tiny pattern generator …
rivos-eblot Nov 13, 2024
f8156e9
[ot] python/qemu: ot.util.log: create a service for remote UDP logging.
rivos-eblot Nov 20, 2024
ceca18e
[ot] scripts/opentitan: pyot.py: add an option to start an UDP log li…
rivos-eblot Nov 20, 2024
30317df
[ot]: python/qemu: ot.util.log: add an API to discard MemoryHandler r…
rivos-eblot Nov 25, 2024
be864fd
[ot] scripts/opentitan: pyot.py: discard memoryhandler logger content…
rivos-eblot Nov 25, 2024
5242000
[ot] scripts/opentitan: pyot.py: limit the length of a reported test …
rivos-eblot Nov 25, 2024
7e15b87
[ot] scripts/opentitan: pyot.py: add a small delay on exit to handle …
rivos-eblot Nov 27, 2024
7c98542
[ot] python/qemu: reorganize and clean up jtag module.
rivos-eblot Nov 21, 2024
5636562
[ot] python/qemu: bitbang.py: update the new write_tms API from jtagt…
rivos-eblot Nov 22, 2024
2087a41
[ot] scripts/opentitan: dtm: add support for PyFtdi.
rivos-eblot Nov 22, 2024
470fcba
[ot] scripts/opentitan: dtm.py add support for custom DTMCS and DMI r…
rivos-eblot Nov 21, 2024
b23df94
[ot] hw/jtag: tap_ctrl_rbb: ensure socket is configured with nodelay
rivos-eblot Nov 25, 2024
131c320
[ot] python/qemu: jtagtools.rbb: ensure TCP socket is configured with…
rivos-eblot Nov 25, 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
2 changes: 1 addition & 1 deletion .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
- name: Lint Python code
run: |
pylint --rcfile scripts/opentitan/.pylintrc -d 'duplicate-code' -d 'fixme' \
scripts/opentitan/*.py python/qemu/jtag python/qemu/ot
scripts/opentitan/*.py python/qemu/jtagtools python/qemu/ot

lint-clang:
runs-on: ubuntu-latest
Expand Down
14 changes: 9 additions & 5 deletions docs/opentitan/dtm.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ Extras:
operation, `--file` argument is mandatory. The content of the binary file is copied into the
memory, starting at the `--address`. See also the `--elf` option for uploading applications.

* `-S` specify the socket info of the JTAG server in the QEMU VM. For TCP, this should follow the
setting of the `-chardev socket,id=taprbb,host=<host>,port=<num>,...` option for invoking QEMU.
For unix sockets, host/port are replaced with the unix socket path specified instead:
`-chardev socket,id=taprbb,path=<socket/path>`.
* `-S` specify the socket info to connect to the remote device.
* for QEMU VM JTAG server, TCP and Unix sockets are supported, _i.e._ `tcp:host:port` or
`unix:path/to/socket`.
* For TCP, this should follow the setting of the
`-chardev socket,id=taprbb,host=<host>,port=<num>,...` option for invoking QEMU.
* for Unix sockets, host/port are replaced with the unix socket path specified instead:
`-chardev socket,id=taprbb,path=<socket/path>`.
* for FTDI *232H USB-JTAG interfaces, PyFtdi v0.59+ Python module should be installed, and
pyftdi URL should be used to specify the FTDI device: _e.g._ `ftdi://ftdi:2232/1`

* `-s` specify the number of bytes to read from or write to memory. Useful with the `--mem` option.
See also the `--address` option. This option may be omitted for the `write` memory operation, in
Expand Down Expand Up @@ -134,4 +139,3 @@ option:
./scripts/opentitan/dtm.py -m write -a 0x1000_0000 -f file.dat -X

````

65 changes: 31 additions & 34 deletions docs/opentitan/pyot.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,70 +11,63 @@ usage: pyot.py [-h] [-D DELAY] [-i ICOUNT] [-L LOG_FILE] [-M VARIANT] [-N LOG]
[-f RAW] [-g file] [-K] [-l file] [-O RAW] [-o VMEM] [-r ELF]
[-w CSV] [-x file] [-X] [-F TEST] [-k SECONDS] [-z] [-R]
[-T FACTOR] [-Z] [-v] [-V] [-d] [--quiet] [--log-time]
[--debug LOGGER] [--info LOGGER] [--warn LOGGER]
[--log-udp UDP_PORT] [--debug LOGGER] [--info LOGGER]
[--warn LOGGER]

OpenTitan QEMU unit test sequencer.

options:
-h, --help show this help message and exit

Virtual machine:
-D DELAY, --start-delay DELAY
-D, --start-delay DELAY
QEMU start up delay before initial comm
-i ICOUNT, --icount ICOUNT
virtual instruction counter with 2^ICOUNT clock ticks
-i, --icount ICOUNT virtual instruction counter with 2^ICOUNT clock ticks
per inst. or 'auto'
-L LOG_FILE, --log_file LOG_FILE
-L, --log_file LOG_FILE
log file for trace and log messages
-M VARIANT, --variant VARIANT
-M, --variant VARIANT
machine variant (machine specific)
-N LOG, --log LOG log message types
-m MACHINE, --machine MACHINE
-N, --log LOG log message types
-m, --machine MACHINE
virtual machine (default to ot-earlgrey)
-Q OPTS, --opts OPTS QEMU verbatim option (can be repeated)
-q QEMU, --qemu QEMU path to qemu application (default: build/qemu-system-
-Q, --opts OPTS QEMU verbatim option (can be repeated)
-q, --qemu QEMU path to qemu application (default: build/qemu-system-
riscv32)
-P VCP, --vcp VCP serial port devices (default: use serial0)
-p DEVICE, --device DEVICE
serial port device name / template name (default to
-P, --vcp VCP serial port devices (default: use serial0)
-p, --device DEVICE serial port device name / template name (default to
localhost:8000)
-t TRACE, --trace TRACE
trace event definition file
-S FIRST_SOC, --first-soc FIRST_SOC
-t, --trace TRACE trace event definition file
-S, --first-soc FIRST_SOC
Identifier of the first SoC, if any
-s, --singlestep enable "single stepping" QEMU execution mode
-U, --muxserial enable multiple virtual UARTs to be muxed into same
host output channel

Files:
-b file, --boot file bootloader 0 file
-c HJSON, --config HJSON
path to HJSON configuration file
-b, --boot file bootloader 0 file
-c, --config HJSON path to HJSON configuration file
-e, --embedded-flash generate an embedded flash image file
-f RAW, --flash RAW SPI flash image file
-g file, --otcfg file
configuration options for OpenTitan devices
-f, --flash RAW SPI flash image file
-g, --otcfg file configuration options for OpenTitan devices
-K, --keep-tmp Do not automatically remove temporary files and dirs
on exit
-l file, --loader file
ROM trampoline to execute, if any
-O RAW, --otp-raw RAW
OTP image file
-o VMEM, --otp VMEM OTP VMEM file
-r ELF, --rom ELF ROM file (can be repeated, in load order)
-w CSV, --result CSV path to output result file
-x file, --exec file application to load
-l, --loader file ROM trampoline to execute, if any
-O, --otp-raw RAW OTP image file
-o, --otp VMEM OTP VMEM file
-r, --rom ELF ROM file (can be repeated, in load order)
-w, --result CSV path to output result file
-x, --exec file application to load
-X, --rom-exec load application as ROM image (default: as kernel)

Execution:
-F TEST, --filter TEST
run tests with matching filter, prefix with "!" to
-F, --filter TEST run tests with matching filter, prefix with "!" to
exclude matching tests
-k SECONDS, --timeout SECONDS
-k, --timeout SECONDS
exit after the specified seconds (default: 60 secs)
-z, --list show a list of tests to execute and exit
-R, --summary show a result summary
-T FACTOR, --timeout-factor FACTOR
-T, --timeout-factor FACTOR
timeout factor
-Z, --zero do not error if no test can be executed

Expand All @@ -84,6 +77,7 @@ Extras:
-d enable debug mode
--quiet quiet logging: only be verbose on errors
--log-time show local time in log messages
--log-udp UDP_PORT Change UDP port for log messages, use 0 to disable
--debug LOGGER assign debug level to logger(s)
--info LOGGER assign info level to logger(s)
--warn LOGGER assign warning level to logger(s)
Expand Down Expand Up @@ -185,6 +179,8 @@ This tool may be used in two ways, which can be combined:
* `-d` only useful to debug the script, reports any Python traceback to the standard error stream.
* `--quiet` only emit verbose log traces if an error is detected
* `--log-time` show local time before each logged message
* `--log-udp` change the port of the UDP log service on specified UDP port. Use `0` to disable the
service.
* `--debug` enable the debug level for the selected logger, may be repeated
* `--info` enable the info level for the selected logger, may be repeated
* `--warn` enable the warning level for the selected logger, may be repeated
Expand Down Expand Up @@ -386,6 +382,7 @@ Sample config for running some non-OpenTitan tests:
* `${UTPATH}` absolute path to the executed OT test
* `${UTDIR}` absolute path to the directory containing the executed OT test
* `${UTFILE}` file name of the executed OT test (without directory specifier)
* `${UDPLOG}` UDP log service, if UDP log service has been enabled, see `--log-udp` option.

* `testdir`
This section may be used to define the default path where to look for tests to run.
Expand Down
7 changes: 7 additions & 0 deletions hw/jtag/tap_ctrl_rbb.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "qapi/error.h"
#include "qom/object.h"
#include "chardev/char-fe.h"
#include "chardev/char-socket.h"
#include "chardev/char.h"
#include "hw/jtag/tap_ctrl.h"
#include "hw/jtag/tap_ctrl_rbb.h"
Expand Down Expand Up @@ -511,6 +512,12 @@ static void tap_ctrl_rbb_chr_event_hander(void *opaque, QEMUChrEvent event)
return;
}

Object *sock;
sock = object_dynamic_cast(OBJECT(tap->chr.chr), TYPE_CHARDEV_SOCKET);
if (sock) {
qio_channel_set_delay(SOCKET_CHARDEV(sock)->ioc, false);
}

tap_ctrl_rbb_tap_reset(tap);
}
}
Expand Down
35 changes: 28 additions & 7 deletions hw/opentitan/ot_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,16 @@ struct OtDMAState {
OtDMAOp op;
OtDMASHA sha;
uint32_t *regs;
unsigned tb_size; /* DMA transfer block size */
OtDMAControl control; /* captured regs on initial IDLE-GO transition */
bool abort;

char *ot_id;
char *ot_as_name; /* private AS unique name */
char *ctn_as_name; /* externel port AS unique name */
char *sys_as_name; /* external system AS unique name */
uint32_t pace_delay; /* pace DMA scheduling (ns) */
uint8_t block_size_lg2; /* log2 of DMA transfer block size */
#ifdef OT_DMA_HAS_ROLE
uint8_t role;
#endif
Expand All @@ -287,9 +290,9 @@ struct OtDMAState {

#define DMA_ERROR(_err_) (1u << (_err_))

/* the following values are arbitrary end may be changed if needed */
#define DMA_PACE_NS 10000u /* 10us: slow down DMA, handle aborts */
#define DMA_TRANSFER_BLOCK_SIZE 4096u /* size of a single DMA block */
/* default values, can be overridden with properties */
#define DMA_PACE_NS 10000u /* 10us: slow down DMA, handle aborts */
#define DMA_TRANSFER_BLOCK_LG2 12u /* log2(size) of a single DMA block */

#define REG_NAME_ENTRY(_reg_) [R_##_reg_] = stringify(_reg_)
static const char *REG_NAMES[REGS_COUNT] = {
Expand Down Expand Up @@ -922,7 +925,7 @@ static bool ot_dma_go(OtDMAState *s)

timer_del(s->timer);
uint64_t now = qemu_clock_get_ns(OT_VIRTUAL_CLOCK);
timer_mod(s->timer, (int64_t)(now + DMA_PACE_NS));
timer_mod_anticipate(s->timer, (int64_t)(now + s->pace_delay));

return true;
}
Expand All @@ -941,7 +944,7 @@ static void ot_dma_abort(OtDMAState *s)
/* simulate a delayed response */
timer_del(s->timer);
uint64_t now = qemu_clock_get_ns(OT_VIRTUAL_CLOCK);
timer_mod(s->timer, (int64_t)(now + DMA_PACE_NS));
timer_mod(s->timer, (int64_t)(now + s->pace_delay));
}

static void ot_dma_complete(OtDMAState *s)
Expand Down Expand Up @@ -1037,7 +1040,7 @@ static void ot_dma_transfer(void *opaque)

smp_mb();

hwaddr size = MIN(op->size, DMA_TRANSFER_BLOCK_SIZE);
hwaddr size = MIN(op->size, s->tb_size);

CHANGE_STATE(s, SEND_WRITE);

Expand All @@ -1062,7 +1065,7 @@ static void ot_dma_transfer(void *opaque)

/* schedule next block if any */
uint64_t now = qemu_clock_get_ns(OT_VIRTUAL_CLOCK);
timer_mod(s->timer, (int64_t)(now + DMA_PACE_NS));
timer_mod(s->timer, (int64_t)(now + s->pace_delay));
return;
}
}
Expand Down Expand Up @@ -1313,6 +1316,9 @@ static Property ot_dma_properties[] = {
DEFINE_PROP_STRING("ot_as_name", OtDMAState, ot_as_name),
DEFINE_PROP_STRING("ctn_as_name", OtDMAState, ctn_as_name),
DEFINE_PROP_STRING("sys_as_name", OtDMAState, sys_as_name),
DEFINE_PROP_UINT32("pace_delay", OtDMAState, pace_delay, DMA_PACE_NS),
DEFINE_PROP_UINT8("block_size_lg2", OtDMAState, block_size_lg2,
DMA_TRANSFER_BLOCK_LG2),
#ifdef OT_DMA_HAS_ROLE
DEFINE_PROP_UINT8("role", OtDMAState, role, UINT8_MAX),
#endif
Expand Down Expand Up @@ -1376,6 +1382,20 @@ static void ot_dma_reset(DeviceState *dev)
}
}

static void ot_dma_realize(DeviceState *dev, Error **errp)
{
OtDMAState *s = OT_DMA(dev);
(void)errp;

if (s->block_size_lg2 < 8u || s->block_size_lg2 > 20u) {
error_setg(&error_fatal, "%s: invalid DMA transfer block size: %u",
__func__, 1u << s->block_size_lg2);
return;
}

s->tb_size = 1u << s->block_size_lg2;
}

static void ot_dma_init(Object *obj)
{
OtDMAState *s = OT_DMA(obj);
Expand All @@ -1401,6 +1421,7 @@ static void ot_dma_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
(void)data;

dc->realize = &ot_dma_realize;
dc->reset = &ot_dma_reset;
device_class_set_props(dc, ot_dma_properties);
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
Expand Down
Loading
Loading