From 0e326442798da98b80935cfdae9cfd0325ef86d8 Mon Sep 17 00:00:00 2001 From: Andrei Gherzan Date: Wed, 14 Oct 2026 19:49:29 +0100 Subject: [PATCH] rpi-config: make DWC2 USB modes mutually exclusive ENABLE_DWC2_HOST was not checked against the other DWC2 modes, so enabling it with ENABLE_DWC2_PERIPHERAL or ENABLE_DWC2_OTG resulted in conflicting dr_mode overlays in config.txt. Enabling both PERIPHERAL and OTG resulted in no overlay at all. Fail the build when more than one mode is enabled. Fixes #1590 Signed-off-by: Andrei Gherzan --- recipes-bsp/bootfiles/rpi-config_git.bb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/recipes-bsp/bootfiles/rpi-config_git.bb b/recipes-bsp/bootfiles/rpi-config_git.bb index 2c21536..33dd5d1 100644 --- a/recipes-bsp/bootfiles/rpi-config_git.bb +++ b/recipes-bsp/bootfiles/rpi-config_git.bb @@ -247,20 +247,17 @@ do_deploy() { echo "hdmi_drive=1" >> $CONFIG fi - # DWC2 USB peripheral support - if ([ "${ENABLE_DWC2_PERIPHERAL}" = "1" ] && [ "${ENABLE_DWC2_OTG}" != "1" ]); then + # DWC2 USB support (peripheral, host or OTG - mutually exclusive) + if [ "${@sum(d.getVar(v) == '1' for v in ['ENABLE_DWC2_PERIPHERAL', 'ENABLE_DWC2_HOST', 'ENABLE_DWC2_OTG'])}" -gt 1 ]; then + bbfatal "Only one of ENABLE_DWC2_PERIPHERAL, ENABLE_DWC2_HOST and ENABLE_DWC2_OTG can be enabled" + fi + if [ "${ENABLE_DWC2_PERIPHERAL}" = "1" ]; then echo "# Enable USB peripheral mode" >> $CONFIG echo "dtoverlay=dwc2,dr_mode=peripheral" >> $CONFIG - fi - - # DWC2 USB host mode support - if [ "${ENABLE_DWC2_HOST}" = "1" ]; then + elif [ "${ENABLE_DWC2_HOST}" = "1" ]; then echo "# Enable USB host mode" >> $CONFIG echo "dtoverlay=dwc2,dr_mode=host" >> $CONFIG - fi - - # DWC2 USB OTG support - if ([ "${ENABLE_DWC2_OTG}" = "1" ] && [ "${ENABLE_DWC2_PERIPHERAL}" != "1" ]); then + elif [ "${ENABLE_DWC2_OTG}" = "1" ]; then echo "# Enable USB OTG mode" >> $CONFIG echo "dtoverlay=dwc2,dr_mode=otg" >> $CONFIG fi