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.
Battery Life Impact
Enabling logging increases the power usage of your keyboard, and can have a non-trivial impact to your time on battery. It is recommended to only enable logging when needed, and not leaving it on by default.
CONFIG_ZMK_USB_LOGGING KConfig value needs to be set, either by copy and pasting into the
app/prj.conf file, or by running
west build -t menuconfig and manually enabling the setting in that UI at
ZMK -> Advanced -> USB Logging.
If you are debugging your own keyboard in your user config repository, use
config/boards/shields/<your_keyboard>/<your_keyboard>.conf instead of
app/prj.conf. In Github
Actions, you can search the
Kconfig file build log to verify the options above have been enabled
for you successfully.
After flashing the updated ZMK image, the board should expose a USB CDC ACM device that you can connect to and view the logs.
On Linux, this should be a device like
/dev/ttyACM0 and you can connect with
tio as usual, e.g.:
On Windows, you can use PuTTY. 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.
If you already have the Ardunio IDE installed you can also use its built-in Serial Monitor.
You should see tio printing
Connected when you disconnect or reconnect the USB cable.
From there, you should see the various log messages from ZMK and Zephyr, depending on which systems you have set to what log levels.