1.. zephyr:code-sample:: console_echo 2 :name: Console echo 3 :relevant-api: console_api 4 5 Echo an input character back to the output using the Console API. 6 7Overview 8******** 9 10This example shows how the :c:func:`console_getchar` and 11:c:func:`console_putchar` functions can be used to echo an input character 12back to the console. 13 14Requirements 15************ 16 17UART console is required to run this sample. 18 19Building and Running 20******************** 21 22Build and flash the sample as follows, changing ``nucleo_f401re`` for your 23board. Alternatively you can run this using QEMU, as described in 24:zephyr:code-sample:`console_getchar`. 25 26.. zephyr-app-commands:: 27 :zephyr-app: samples/subsys/console/echo 28 :host-os: unix 29 :board: nucleo_f401re 30 :goals: build flash 31 :compact: 32 33Following the initial prompt given by the firmware, start pressing keys on a 34keyboard, and they will be echoed back to the terminal program you are using. 35 36Running on QEMU 37=============== 38 39On QEMU you can use the VIRTIO console device. It is already configured in 40Zephyr. To use it, run: 41 42.. zephyr-app-commands:: 43 :zephyr-app: samples/subsys/console/echo 44 :board: qemu_x86_64 45 :gen-args: -DDTC_OVERLAY_FILE=virtconsole.overlay -DEXTRA_CONF_FILE=overlay-virtconsole.conf 46 :goals: run 47 :compact: 48 49It is possible to use multiple inputs/outputs at once by configuring them 50in the ``overlay-virtconsole.conf`` file. 51 52* Add ``CONFIG_UART_VIRTIO_CONSOLE_F_MULTIPORT=y`` to enable the 53 multiport feature. 54* Configure more ports using the ``CONFIG_QEMU_EXTRA_FLAGS`` option. 55 Refer to the QEMU manual for details. 56 57Sample Output 58============= 59 60.. code-block:: console 61 62 You should see another line with instructions below. If not, 63 the (interrupt-driven) console device doesn't work as expected: 64 Start typing characters to see them echoed back 65