boards: add common configuration for CDC ACM UART
Many boards have similar code to configure the USB and CDC ACM UART that they want to use as a logging or shell backend. Some of them have an incorrect or incomplete configuration. These boards do not have a built-in debug adapter, but a SoC with a USB device controller and a bootloader with USB device support. Introduce common CDC ACM UART configuration that these boards should use for logging or shell backend to avoid duplicate or incorrect configuration. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
parent
c4923b6be0
commit
0cae816b27
3 changed files with 86 additions and 0 deletions
|
|
@ -128,6 +128,20 @@ config QEMU_EXTRA_FLAGS
|
||||||
to setup devices, for example to allocate interface for Zephyr
|
to setup devices, for example to allocate interface for Zephyr
|
||||||
GDBstub over serial with `-serial tcp:127.0.0.1:5678,server`
|
GDBstub over serial with `-serial tcp:127.0.0.1:5678,server`
|
||||||
|
|
||||||
|
config BOARD_REQUIRES_SERIAL_BACKEND_CDC_ACM
|
||||||
|
bool
|
||||||
|
help
|
||||||
|
Indicates that a board has no other capabilities than to use the CDC
|
||||||
|
ACM UART as a backend for logging or shell.
|
||||||
|
|
||||||
|
config BOARD_SERIAL_BACKEND_CDC_ACM
|
||||||
|
bool "Board uses USB CDC ACM UART as serial backend"
|
||||||
|
depends on BOARD_REQUIRES_SERIAL_BACKEND_CDC_ACM
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
USB stack and CDC ACM UART are configured and initialized at boot
|
||||||
|
time to be used as a backend for logging or shell.
|
||||||
|
|
||||||
# There might not be any board options, hence the optional source
|
# There might not be any board options, hence the optional source
|
||||||
osource "$(KCONFIG_BOARD_DIR)/Kconfig"
|
osource "$(KCONFIG_BOARD_DIR)/Kconfig"
|
||||||
endmenu
|
endmenu
|
||||||
|
|
|
||||||
51
boards/common/usb/Kconfig.cdc_acm_serial.defconfig
Normal file
51
boards/common/usb/Kconfig.cdc_acm_serial.defconfig
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
# Copyright (c) 2023-2024 Nordic Semiconductor ASA
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
config BOARD_REQUIRES_SERIAL_BACKEND_CDC_ACM
|
||||||
|
default y
|
||||||
|
|
||||||
|
if BOARD_SERIAL_BACKEND_CDC_ACM
|
||||||
|
|
||||||
|
config SERIAL
|
||||||
|
default y
|
||||||
|
|
||||||
|
config CONSOLE
|
||||||
|
default y
|
||||||
|
|
||||||
|
config UART_CONSOLE
|
||||||
|
default CONSOLE
|
||||||
|
|
||||||
|
config SHELL_BACKEND_SERIAL_CHECK_DTR
|
||||||
|
default SHELL
|
||||||
|
depends on UART_LINE_CTRL
|
||||||
|
|
||||||
|
config UART_LINE_CTRL
|
||||||
|
default SHELL
|
||||||
|
|
||||||
|
config USB_DEVICE_STACK
|
||||||
|
default y
|
||||||
|
|
||||||
|
config USB_DEVICE_INITIALIZE_AT_BOOT
|
||||||
|
default y if !MCUBOOT
|
||||||
|
|
||||||
|
config USB_DEVICE_REMOTE_WAKEUP
|
||||||
|
default n
|
||||||
|
|
||||||
|
if LOG
|
||||||
|
|
||||||
|
choice USB_CDC_ACM_LOG_LEVEL_CHOICE
|
||||||
|
default USB_CDC_ACM_LOG_LEVEL_OFF
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
choice USB_DEVICE_LOG_LEVEL_CHOICE
|
||||||
|
default USB_DEVICE_LOG_LEVEL_OFF
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
# Wait 4000ms at startup for logging
|
||||||
|
config LOG_PROCESS_THREAD_STARTUP_DELAY_MS
|
||||||
|
default 4000
|
||||||
|
|
||||||
|
endif # LOG
|
||||||
|
|
||||||
|
endif # BOARD_SERIAL_BACKEND_CDC_ACM
|
||||||
21
boards/common/usb/cdc_acm_serial.dtsi
Normal file
21
boards/common/usb/cdc_acm_serial.dtsi
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 Nordic Semiconductor ASA
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
chosen {
|
||||||
|
zephyr,console = &board_cdc_acm_uart;
|
||||||
|
zephyr,shell-uart = &board_cdc_acm_uart;
|
||||||
|
zephyr,uart-mcumgr = &board_cdc_acm_uart;
|
||||||
|
zephyr,bt-mon-uart = &board_cdc_acm_uart;
|
||||||
|
zephyr,bt-c2h-uart = &board_cdc_acm_uart;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
&zephyr_udc0 {
|
||||||
|
board_cdc_acm_uart: board_cdc_acm_uart {
|
||||||
|
compatible = "zephyr,cdc-acm-uart";
|
||||||
|
};
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue