|
| 1 | +# OpenTitan UART Support |
| 2 | + |
| 3 | +## Connecting to the UART |
| 4 | + |
| 5 | +* `-serial mon:stdio`, used as the first `-serial` option, redirects the virtual UART0 to the |
| 6 | + current console/shell. |
| 7 | + |
| 8 | +* `-chardev socket,id=serial1,host=localhost,port=8001,server=on,wait=off` and |
| 9 | + `-serial chardev:serial1` can be used to redirect UART1 (in this example) to a TCP socket. These |
| 10 | + options are not specific to OpenTitan emulation, but are useful to communicate over a UART. |
| 11 | + Note that QEMU offers many `chardev` backends, please check QEMU documentation for details. |
| 12 | + |
| 13 | +## Sending Break Conditions |
| 14 | + |
| 15 | +Break conditions can be sent to the UART on select supported CharDev backends (telnet, mux) |
| 16 | +or by sending the `chardev-send-break` command with the CharDev ID via the QEMU Monitor. |
| 17 | +Break conditions are treated as transient events and the length of time of a break condition |
| 18 | +is not considered. |
| 19 | + |
| 20 | +## Oversampling |
| 21 | + |
| 22 | +OpenTitan's UART has a `VAL` register which oversamples the RX pin 16 times per bit. |
| 23 | +This cannot be emulated by QEMU which uses a CharDev backend and does not have a notion of |
| 24 | +accurate sampling times. |
| 25 | + |
| 26 | +If software wishes to poll the `VAL` register to determine break conditions, there are |
| 27 | +some properties available to help with emulating this use case: |
| 28 | + |
| 29 | +* `-global ot-uart.oversample-break=true` is used to enable UART break oversampling. |
| 30 | + This will attempt to display 16 samples of the last bit received in the `VAL` register, |
| 31 | + which will be 16 high bits after any UART frame is transmitted (as these end with a stop |
| 32 | + bit, which is high), or 16 low bits if the UART previously received a break condition |
| 33 | + and has not received any frames since. That is, enabling this property assumes that |
| 34 | + transmitted break conditions are "held" until the next UART transfer in terms of what |
| 35 | + is being shown in the oversampled `VAL` register. |
| 36 | + |
| 37 | +* `-global ot-uart.toggle-break=true` is used to provide more control over "holding" |
| 38 | + the UART RX break condition like a GPIO strap, and changes the behavior of a UART |
| 39 | + such that received break condition events now *toggle* the break condition state |
| 40 | + rather than keeping it asserted until the next transfer. This allows any device talking |
| 41 | + to OpenTitan via UART to have more precise control over when the UART VAL register |
| 42 | + displays idle and when it displays a break condition, as it can precisely toggle the |
| 43 | + break condition on or off like a GPIO strapping being held down. |
0 commit comments