zmk_mf68/docs/docs/dev-guide-usb-logging.md

77 lines
2.2 KiB
Markdown
Raw Normal View History

2020-07-08 01:58:12 +10:00
---
id: dev-guide-usb-logging
title: USB Logging
---
2020-08-30 08:05:43 +10:00
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
2020-07-08 01:58:12 +10:00
## Overview
If you are developing ZMK on a device that does not have a built in UART for debugging and log/console output,
Zephyr can be configured to create a USB CDC ACM device and the direct all `printk`, console output, and log
messages to that device instead.
## Kconfig
2020-08-30 08:05:43 +10:00
The following KConfig values need to be set, either by copy and pasting into the `app/prj.conf` file, or by running
2020-07-08 01:58:12 +10:00
`west build -t menuconfig` and manually enabling the various settings in that UI.
```
# Turn on logging, and set ZMK logging to debug output
CONFIG_LOG=y
CONFIG_ZMK_LOG_LEVEL_DBG=y
# Turn on USB CDC ACM device
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
2020-07-08 01:58:12 +10:00
CONFIG_USB_CDC_ACM=y
CONFIG_USB_CDC_ACM_RINGBUF_SIZE=1024
CONFIG_USB_CDC_ACM_DEVICE_NAME="CDC_ACM"
CONFIG_USB_CDC_ACM_DEVICE_COUNT=1
# Enable serial console
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
# Enable USB UART, and set the console device
CONFIG_UART_CONSOLE=y
CONFIG_USB_UART_CONSOLE=y
CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0"
CONFIG_USB_UART_DTR_WAIT=n
```
## Viewing Logs
2020-08-30 08:05:43 +10:00
After flashing the updated ZMK image, the board should expose a USB CDC ACM device that you can connect to and view the logs.
2020-07-08 01:58:12 +10:00
2020-08-30 08:05:43 +10:00
<Tabs
defaultValue="linux"
values={[
{label: 'Linux', value: 'linux'},
{label: 'Windows', value: 'win'},
2020-08-30 08:05:43 +10:00
]}>
<TabItem value="linux">
2020-07-08 01:58:12 +10:00
2020-08-30 08:05:43 +10:00
On Linux, this should be a device like `/dev/ttyACM0` and you can connect with `minicom` or `tio` as usual, e.g.:
2020-07-08 01:58:12 +10:00
```
sudo tio /dev/ttyACM0
```
2020-08-30 08:05:43 +10:00
</TabItem>
<TabItem value="win">
2020-08-30 08:05:43 +10:00
2020-08-30 12:22:43 +10:00
On Windows, you can use [PuTTY](https://www.putty.org/). Once installed, use Device Manager to figure out which COM port your controller is communicating on (listed under 'Ports (COM & LPT)') and specify that as the 'Serial line' in PuTTY.
2020-08-30 14:20:38 +10:00
![Controller COM port](./assets/usb-logging/com.jpg)
2020-08-30 12:22:43 +10:00
2020-08-30 14:27:03 +10:00
![PuTTY settings](assets/usb-logging/putty.jpg)
2020-08-30 12:22:43 +10:00
If you already have the Ardunio IDE installed you can also use its built-in Serial Monitor.
2020-08-30 08:05:43 +10:00
</TabItem>
</Tabs>
2020-07-08 01:58:12 +10:00
From there, you should see the various log messages from ZMK and Zephyr, depending on which systems you have set to what log levels.