diff --git a/snippets/cdc-acm-console/README.rst b/snippets/cdc-acm-console/README.rst new file mode 100644 index 00000000000..c1d165b771d --- /dev/null +++ b/snippets/cdc-acm-console/README.rst @@ -0,0 +1,36 @@ +.. _snippet-cdc-acm-console: + +CDC-ACM Console Snippet (cdc-acm-console) +######################################### + +.. code-block:: console + + west build -S cdc-acm-console [...] + +Overview +******** + +This snippet redirects serial console output to a CDC ACM UART. The USB device +which should be used is configured using :ref:`devicetree`. + +Requirements +************ + +Hardware support for: + +- :kconfig:option:`CONFIG_USB_DEVICE_STACK` +- :kconfig:option:`CONFIG_SERIAL` +- :kconfig:option:`CONFIG_CONSOLE` +- :kconfig:option:`CONFIG_UART_CONSOLE` +- :kconfig:option:`CONFIG_UART_LINE_CTRL` + +A devicetree node with node label ``zephyr_udc0`` that points to an enabled USB +device node with driver support. This should look roughly like this in +:ref:`your devicetree `: + +.. code-block:: DTS + + zephyr_udc0: usbd@deadbeef { + compatible = "vnd,usb-device"; + /* ... */ + }; diff --git a/snippets/cdc-acm-console/cdc-acm-console.conf b/snippets/cdc-acm-console/cdc-acm-console.conf new file mode 100644 index 00000000000..28103411fc3 --- /dev/null +++ b/snippets/cdc-acm-console/cdc-acm-console.conf @@ -0,0 +1,8 @@ +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_DEVICE_PRODUCT="Zephyr USB console sample" +CONFIG_USB_DEVICE_PID=0x0004 + +CONFIG_SERIAL=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y +CONFIG_UART_LINE_CTRL=y diff --git a/snippets/cdc-acm-console/cdc-acm-console.overlay b/snippets/cdc-acm-console/cdc-acm-console.overlay new file mode 100644 index 00000000000..91e61886e52 --- /dev/null +++ b/snippets/cdc-acm-console/cdc-acm-console.overlay @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2021, 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + chosen { + zephyr,console = &snippet_cdc_acm_console_uart; + }; +}; + +&zephyr_udc0 { + snippet_cdc_acm_console_uart: snippet_cdc_acm_console_uart { + compatible = "zephyr,cdc-acm-uart"; + }; +}; diff --git a/snippets/cdc-acm-console/snippet.yml b/snippets/cdc-acm-console/snippet.yml new file mode 100644 index 00000000000..eab58a30a40 --- /dev/null +++ b/snippets/cdc-acm-console/snippet.yml @@ -0,0 +1,4 @@ +name: cdc-acm-console +append: + OVERLAY_CONFIG: cdc-acm-console.conf + DTC_OVERLAY_FILE: cdc-acm-console.overlay