diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig.defconfig b/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig.defconfig index 964bd85868e..dd0d8f9aa17 100644 --- a/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig.defconfig +++ b/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig.defconfig @@ -33,10 +33,11 @@ config USB_DEVICE_REMOTE_WAKEUP if LOG -# Set USB and CDC log level to error only +# Logger cannot use itself to log config USB_CDC_ACM_LOG_LEVEL - default 1 + default 0 +# Set USB log level to error only config USB_DEVICE_LOG_LEVEL default 1 diff --git a/boards/arm/xiao_ble/xiao_ble_defconfig b/boards/arm/xiao_ble/xiao_ble_defconfig index ac0a5b9bb22..faef5befa1f 100644 --- a/boards/arm/xiao_ble/xiao_ble_defconfig +++ b/boards/arm/xiao_ble/xiao_ble_defconfig @@ -19,6 +19,9 @@ CONFIG_SERIAL=y # enable console CONFIG_CONSOLE=y +# Logger cannot use itself to log +CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y + # enable USB CONFIG_USB_DEVICE_STACK=y diff --git a/samples/boards/sensortile_box/prj.conf b/samples/boards/sensortile_box/prj.conf index 71d385731fb..5fd052d1ecf 100644 --- a/samples/boards/sensortile_box/prj.conf +++ b/samples/boards/sensortile_box/prj.conf @@ -21,6 +21,7 @@ CONFIG_USB_DEVICE_VID=0x0483 CONFIG_USB_DEVICE_PID=0x1234 CONFIG_USB_DEVICE_STACK=y CONFIG_USB_DEVICE_PRODUCT="Zephyr CDC SensorTile.box" +CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y CONFIG_UART_INTERRUPT_DRIVEN=y CONFIG_UART_LINE_CTRL=y diff --git a/subsys/usb/device/class/cdc_acm.c b/subsys/usb/device/class/cdc_acm.c index 0c269bd4b2c..5c51c967fe6 100644 --- a/subsys/usb/device/class/cdc_acm.c +++ b/subsys/usb/device/class/cdc_acm.c @@ -56,6 +56,14 @@ /* definitions */ #include +#if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart) \ + && defined(CONFIG_USB_CDC_ACM_LOG_LEVEL) \ + && CONFIG_USB_CDC_ACM_LOG_LEVEL != LOG_LEVEL_NONE +/* Prevent endless recursive logging loop and warn user about it */ +#warning "USB_CDC_ACM_LOG_LEVEL forced to LOG_LEVEL_NONE" +#undef CONFIG_USB_CDC_ACM_LOG_LEVEL +#define CONFIG_USB_CDC_ACM_LOG_LEVEL LOG_LEVEL_NONE +#endif LOG_MODULE_REGISTER(usb_cdc_acm, CONFIG_USB_CDC_ACM_LOG_LEVEL); /* 115200bps, no parity, 1 stop bit, 8bit char */