Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards: add common configuration for CDC ACM UART #81308

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jfischer-no
Copy link
Collaborator

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.

Derived from #81220 and #81228, as first step (or alternative).

rerickson1
rerickson1 previously approved these changes Nov 12, 2024
Copy link
Member

@rerickson1 rerickson1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ezurio boards look ok

};

zephyr_udc0: &usbd {
cdc_acm_uart: cdc_acm_uart {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this not be cdc_acm_uart0 if it supports multiple instances?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cdc_acm_uart0 is likely to conflict with samples or user applications, we should rather name it board_cdc_acm_uart, like we prefix snippets and shields.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

board_* prefix sounds good

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also moved them to boards/common/usb/

endif # LOG

endif # USB_DEVICE_STACK
source "${ZEPHYR_BASE}/boards/common/Kconfig.cdc_acm_serial"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick:
Harmonize path between Kconfig and dts:
source "../boards/common/Kconfig.cdc_acm_serial"
#include <../boards/common/cdc_acm_serial.dts>
or
source "${ZEPHYR_BASE}/boards/common/Kconfig.cdc_acm_serial"
#include <${ZEPHYR_BASE}/boards/common/cdc_acm_serial.dts>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${ZEPHYR_BASE} cannot be resolved in dt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we then use ../boards/common for Kconfig ?

nordicjm
nordicjm previously approved these changes Nov 13, 2024
boards/st/sensortile_box_pro/Kconfig.defconfig Outdated Show resolved Hide resolved
boards/st/steval_stwinbx1/Kconfig.defconfig Outdated Show resolved Hide resolved
@@ -9,4 +9,6 @@ if BOARD_ADAFRUIT_FEATHER_NRF52840
config BT_CTLR
default BT

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would enable CDC ACM on the 2 non UF2 variants of this board which currently don't have it enabled. Is that the intended outcome?

I struggled to deal with this when creating these variants. I've since realised perhaps using if BOARD_TARGET = would have been a better way of dealing with some of the variations. Perhaps that would work here. It would be great to be using common definitions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have only selected this for the specific boards in Kconfig you don’t need the if here do you?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, it can now be removed. Thanks.

erwango
erwango previously approved these changes Nov 14, 2024
marwaiehm-st
marwaiehm-st previously approved these changes Nov 14, 2024
rerickson1
rerickson1 previously approved these changes Nov 14, 2024
@jfischer-no jfischer-no force-pushed the pr-boards-common-cdc_acm_serial-only branch 2 times, most recently from 3c7c271 to 1f36b38 Compare November 14, 2024 21:53
Comment on lines 18 to 19
# Logger cannot use itself to log
CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, removed.

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 <[email protected]>
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]>
The board hardware has no network interfaces, although the ECM/EEM class
implementation can provide Ethernet-like functionality and export it to
the host, this is no reason to default to a specific USB class
implementation.We do not make this kind of configuration for other
boards that have a USB device controller. Also, it may not be what a
user expects when using these boards with networking and a USB stack.

Signed-off-by: Johann Fischer <[email protected]>
@jfischer-no jfischer-no force-pushed the pr-boards-common-cdc_acm_serial-only branch from 1f36b38 to b9a3072 Compare November 15, 2024 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants