Skip to content

Commit

Permalink
boards: use board common CDC ACM UART configuration
Browse files Browse the repository at this point in the history
Remove all USB and CDC ACM configuration in favor of common
configuraiton.

Do not adapt board-specific configurations such as unknown PID/VID or
string descriptors. There is no justification for using them on specific
boards, and we do not have formal approval to use them in the project
tree. Also, we need more uniform configuration, since the main reason
for enabling CDC ACM here is to allow users to run examples like
hello_world right out of the box. Of course, anyone is free to customize
these settings in their fork or downstream project.

Signed-off-by: Johann Fischer <[email protected]>
  • Loading branch information
jfischer-no committed Nov 15, 2024
1 parent 7aa9e3a commit 0fa745d
Show file tree
Hide file tree
Showing 69 changed files with 182 additions and 714 deletions.
10 changes: 10 additions & 0 deletions boards/adafruit/feather_nrf52840/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

if BOARD_ADAFRUIT_FEATHER_NRF52840_NRF52840_UF2 || BOARD_ADAFRUIT_FEATHER_NRF52840_NRF52840_SENSE_UF2

config BOARD_NEED_SERIAL_BACKEND_CDC_ACM
bool
default y

endif
2 changes: 2 additions & 0 deletions boards/adafruit/feather_nrf52840/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ if BOARD_ADAFRUIT_FEATHER_NRF52840
config BT_CTLR
default BT

source "${ZEPHYR_BASE}/boards/common/usb/Kconfig.cdc_acm_serial"

endif # BOARD_ADAFRUIT_FEATHER_NRF52840
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@
/dts-v1/;
#include "adafruit_feather_nrf52840_common.dtsi"
#include <nordic/nrf52840_partition_uf2_sdv6.dtsi>
#include <../boards/common/usb/cdc_acm_serial.dtsi>

/ {
model = "Adafruit Feather nRF52840 Sense";
compatible = "adafruit,feather-nrf52840-sense-uf2";

chosen {
zephyr,console = &cdc_acm_uart0;
zephyr,shell-uart = &cdc_acm_uart0;
zephyr,uart-mcumgr = &cdc_acm_uart0;
zephyr,bt-mon-uart = &cdc_acm_uart0;
zephyr,bt-c2h-uart = &cdc_acm_uart0;
};

leds {
led0: led_0 {
gpios = <&gpio1 9 0>;
Expand All @@ -34,9 +27,3 @@
reg = <0x44>;
};
};

zephyr_udc0: &usbd {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,5 @@ CONFIG_UART_CONSOLE=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

# Logger cannot use itself to log
CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y

# Enable USB
CONFIG_USB_DEVICE_STACK=y

# Build UF2 by default, supported by the Adafruit nRF52 Bootloader
CONFIG_BUILD_OUTPUT_UF2=y
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,15 @@
/dts-v1/;
#include "adafruit_feather_nrf52840_common.dtsi"
#include <nordic/nrf52840_partition_uf2_sdv6.dtsi>
#include <../boards/common/usb/cdc_acm_serial.dtsi>

/ {
model = "Adafruit Feather nRF52840 Express";
compatible = "adafruit,feather-nrf52840-uf2";

chosen {
zephyr,console = &cdc_acm_uart0;
zephyr,shell-uart = &cdc_acm_uart0;
zephyr,uart-mcumgr = &cdc_acm_uart0;
zephyr,bt-mon-uart = &cdc_acm_uart0;
zephyr,bt-c2h-uart = &cdc_acm_uart0;
};

leds {
led0: led_0 {
gpios = <&gpio1 15 0>;
};
};
};

zephyr_udc0: &usbd {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,5 @@ CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

# Logger cannot use itself to log
CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y

# Enable USB
CONFIG_USB_DEVICE_STACK=y

# Build UF2 by default, supported by the Adafruit nRF52 Bootloader
CONFIG_BUILD_OUTPUT_UF2=y
4 changes: 2 additions & 2 deletions boards/adafruit/itsybitsy/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2022 Embla Flatlandsmo <[email protected]>
# SPDX-License-Identifier: Apache-2.0

config BOARD_SERIAL_BACKEND_CDC_ACM
bool "USB CDC"
config BOARD_NEED_SERIAL_BACKEND_CDC_ACM
bool
default y
depends on BOARD_ADAFRUIT_ITSYBITSY
42 changes: 1 addition & 41 deletions boards/adafruit/itsybitsy/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,6 @@ if BOARD_ADAFRUIT_ITSYBITSY
config BT_CTLR
default BT

if BOARD_SERIAL_BACKEND_CDC_ACM

config USB_DEVICE_STACK
default y

config USB_CDC_ACM
default SERIAL

config UART_CONSOLE
default CONSOLE

config USB_DEVICE_INITIALIZE_AT_BOOT
default y if CONSOLE

config SHELL_BACKEND_SERIAL_CHECK_DTR
default SHELL
depends on UART_LINE_CTRL

config UART_LINE_CTRL
default SHELL

config USB_DEVICE_REMOTE_WAKEUP
default n

if LOG

# Logger cannot use itself to log
config USB_CDC_ACM_LOG_LEVEL
default 0

# Set USB log level to error only
config USB_DEVICE_LOG_LEVEL
default 1

# Wait 1500ms at startup for logging
config LOG_PROCESS_THREAD_STARTUP_DELAY_MS
default 1500

endif # LOG

endif # BOARD_SERIAL_BACKEND_CDC_ACM
source "${ZEPHYR_BASE}/boards/common/usb/Kconfig.cdc_acm_serial"

endif # BOARD_ADAFRUIT_ITSYBITSY
11 changes: 2 additions & 9 deletions boards/adafruit/itsybitsy/adafruit_itsybitsy_nrf52840.dts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
compatible = "adafruit,itsybitsy-nrf52840";

chosen {
zephyr,console = &cdc_acm_uart0;
zephyr,shell-uart = &cdc_acm_uart0;
zephyr,uart-mcumgr = &cdc_acm_uart0;
zephyr,bt-mon-uart = &cdc_acm_uart0;
zephyr,bt-c2h-uart = &cdc_acm_uart0;
zephyr,ieee802154 = &ieee802154;
};

Expand Down Expand Up @@ -155,8 +150,6 @@
zephyr_udc0: &usbd {
compatible = "nordic,nrf-usbd";
status = "okay";

cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};

#include <../boards/common/usb/cdc_acm_serial.dtsi>
10 changes: 10 additions & 0 deletions boards/arduino/opta/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

if BOARD_ARDUINO_OPTA_STM32H747XX_M7

config BOARD_NEED_SERIAL_BACKEND_CDC_ACM
bool
default y

endif # BOARD_ARDUINO_OPTA_STM32H747XX_M7
30 changes: 1 addition & 29 deletions boards/arduino/opta/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,6 @@ config NET_L2_ETHERNET

endif # NETWORKING

if USB_DEVICE_STACK

config USB_DEVICE_PRODUCT
default "Arduino Opta"

config USB_DEVICE_PID
default 0x0164

config USB_DEVICE_VID
default 0x35d1

config USB_DEVICE_INITIALIZE_AT_BOOT
default y

if LOG

# Logger cannot use itself to log
choice USB_CDC_ACM_LOG_LEVEL_CHOICE
default USB_CDC_ACM_LOG_LEVEL_OFF
endchoice

# Set USB log level to error only
choice USB_DEVICE_LOG_LEVEL_CHOICE
default USB_DEVICE_LOG_LEVEL_ERR
endchoice

endif # LOG

endif # USB_DEVICE_STACK
source "${ZEPHYR_BASE}/boards/common/usb/Kconfig.cdc_acm_serial"

endif # BOARD_ARDUINO_OPTA
13 changes: 2 additions & 11 deletions boards/arduino/opta/arduino_opta_stm32h747xx_m7.dts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
compatible = "arduino,opta-m7";

chosen {
zephyr,console = &cdc_acm_uart0;
zephyr,shell-uart = &cdc_acm_uart0;
zephyr,cdc-acm-uart0 = &cdc_acm_uart0;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
Expand All @@ -45,12 +42,10 @@ zephyr_udc0: &usbotg_fs {
pinctrl-0 = <&usb_otg_fs_dm_pa11 &usb_otg_fs_dp_pa12>;
pinctrl-names = "default";
status = "okay";

cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};

#include <../boards/common/usb/cdc_acm_serial.dtsi>

&clk_hse {
clock-frequency = <DT_FREQ_M(25)>;
hse-bypass;
Expand Down Expand Up @@ -109,10 +104,6 @@ zephyr_udc0: &usbotg_fs {
status = "disabled";
};

&cdc_acm_uart0 {
status = "okay";
};

&mac {
pinctrl-0 = <
&eth_ref_clk_pa1
Expand Down
3 changes: 0 additions & 3 deletions boards/arduino/opta/arduino_opta_stm32h747xx_m7_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_LINE_CTRL=y

# Enable USB Stack (needed for the console to work)
CONFIG_USB_DEVICE_STACK=y

# Enable regulator (needed to enable eth)
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED=y
10 changes: 10 additions & 0 deletions boards/arduino/portenta_h7/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

if BOARD_ARDUINO_PORTENTA_H7_STM32H747XX_M7

config BOARD_NEED_SERIAL_BACKEND_CDC_ACM
bool
default y

endif # BOARD_ARDUINO_PORTENTA_H7_STM32H747XX_M7
30 changes: 1 addition & 29 deletions boards/arduino/portenta_h7/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,6 @@ config NET_L2_ETHERNET

endif # NETWORKING

if USB_DEVICE_STACK

config USB_DEVICE_PRODUCT
default "Arduino SA Portenta H7"

config USB_DEVICE_PID
default 0x035b

config USB_DEVICE_VID
default 0x2341

config USB_DEVICE_INITIALIZE_AT_BOOT
default y

if LOG

# Logger cannot use itself to log
choice USB_CDC_ACM_LOG_LEVEL_CHOICE
default USB_CDC_ACM_LOG_LEVEL_OFF
endchoice

# Set USB log level to error only
choice USB_DEVICE_LOG_LEVEL_CHOICE
default USB_DEVICE_LOG_LEVEL_ERR
endchoice

endif # LOG

endif # USB_DEVICE_STACK
source "${ZEPHYR_BASE}/boards/common/usb/Kconfig.cdc_acm_serial"

endif # BOARD_ARDUINO_PORTENTA_H7
3 changes: 0 additions & 3 deletions boards/arduino/portenta_h7/arduino_portenta_h7-common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,4 @@ zephyr_udc0: &usbotg_hs {
<&rcc STM32_SRC_HSI48 USB_SEL(3)>;
num-bidir-endpoints = < 4 >;
status = "okay";
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
#include <st/h7/stm32h747Xi_m7.dtsi>
#include <st/h7/stm32h747xihx-pinctrl.dtsi>
#include "arduino_portenta_h7-common.dtsi"
#include <../boards/common/usb/cdc_acm_serial.dtsi>

/ {
model = "Arduino Portenta H7 board";
compatible = "arduino,portenta-h7";

/* HW resources are split between CM7 and CM4 */
chosen {
zephyr,console = &cdc_acm_uart0;
zephyr,shell-uart = &cdc_acm_uart0;
zephyr,cdc-acm-uart0 = &cdc_acm_uart0;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
Expand Down Expand Up @@ -98,10 +96,6 @@
status = "okay";
};

&cdc_acm_uart0 {
status = "okay";
};

&flash0 {
partitions {
compatible = "fixed-partitions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,3 @@ CONFIG_UART_LINE_CTRL=y
# Enable regulator
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED=y

# Enable USB Stack
CONFIG_USB_DEVICE_STACK=y
10 changes: 10 additions & 0 deletions boards/atmarktechno/degu_evk/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

if BOARD_DEGU_EVK

config BOARD_NEED_SERIAL_BACKEND_CDC_ACM
bool
default y

endif # BOARD_DEGU_EVK
Loading

0 comments on commit 0fa745d

Please sign in to comment.