diff --git a/app/snippets/zmk-usb-logging/README.rst b/app/snippets/zmk-usb-logging/README.rst new file mode 100644 index 000000000000..6f5314287b14 --- /dev/null +++ b/app/snippets/zmk-usb-logging/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/app/snippets/zmk-usb-logging/snippet.yml b/app/snippets/zmk-usb-logging/snippet.yml new file mode 100644 index 000000000000..8f2180850087 --- /dev/null +++ b/app/snippets/zmk-usb-logging/snippet.yml @@ -0,0 +1,4 @@ +name: zmk-usb-logging +append: + EXTRA_CONF_FILE: zmk-usb-logging.conf + EXTRA_DTC_OVERLAY_FILE: zmk-usb-logging.overlay diff --git a/app/snippets/zmk-usb-logging/zmk-usb-logging.conf b/app/snippets/zmk-usb-logging/zmk-usb-logging.conf new file mode 100644 index 000000000000..57893df5f9db --- /dev/null +++ b/app/snippets/zmk-usb-logging/zmk-usb-logging.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_USB_LOGGING=y + diff --git a/app/snippets/zmk-usb-logging/zmk-usb-logging.overlay b/app/snippets/zmk-usb-logging/zmk-usb-logging.overlay new file mode 100644 index 000000000000..5ceda583f493 --- /dev/null +++ b/app/snippets/zmk-usb-logging/zmk-usb-logging.overlay @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +/ { + chosen { + zephyr,console = &snippet_zmk_usb_logging_uart; + zephyr,shell-uart = &snippet_zmk_usb_logging_uart; + }; +}; + +&zephyr_udc0 { + snippet_zmk_usb_logging_uart: snippet_zmk_usb_logging_uart { + compatible = "zephyr,cdc-acm-uart"; + }; +};