In recipes-bsp/bootfiles/rpi-config_git.bb, the three DWC2 USB mode configuration blocks (lines 250-267) have inconsistent exclusion logic,
which can result in multiple conflicting dtoverlay=dwc2,dr_mode=... lines being written to config.txt.
Current behavior:
- ENABLE_DWC2_PERIPHERAL excludes ENABLE_DWC2_OTG ✓
- ENABLE_DWC2_OTG excludes ENABLE_DWC2_PERIPHERAL ✓
- ENABLE_DWC2_HOST has no exclusion checks ✗
If a user sets both ENABLE_DWC2_HOST=1 and ENABLE_DWC2_PERIPHERAL=1 (or ENABLE_DWC2_OTG=1), both blocks fire and produce conflicting dtoverlay lines:
dtoverlay=dwc2,dr_mode=peripheral
dtoverlay=dwc2,dr_mode=host
According to the linux doc Documentation/devicetree/bindings/usb/usb-drd.yaml. It's an enum, only one dr_mode can be active, so the result is undefined.
Suggested fix:
Replace the three independent if blocks with an elif chain to make mutual exclusivity explicit:
if [ "${ENABLE_DWC2_OTG}" = "1" ]; then
echo "# Enable USB OTG mode" >> $CONFIG
echo "dtoverlay=dwc2,dr_mode=otg" >> $CONFIG
elif [ "${ENABLE_DWC2_PERIPHERAL}" = "1" ]; then
echo "# Enable USB peripheral mode" >> $CONFIG
echo "dtoverlay=dwc2,dr_mode=peripheral" >> $CONFIG
elif [ "${ENABLE_DWC2_HOST}" = "1" ]; then
echo "# Enable USB host mode" >> $CONFIG
echo "dtoverlay=dwc2,dr_mode=host" >> $CONFIG
fi
In recipes-bsp/bootfiles/rpi-config_git.bb, the three DWC2 USB mode configuration blocks (lines 250-267) have inconsistent exclusion logic,
which can result in multiple conflicting dtoverlay=dwc2,dr_mode=... lines being written to config.txt.
Current behavior:
If a user sets both ENABLE_DWC2_HOST=1 and ENABLE_DWC2_PERIPHERAL=1 (or ENABLE_DWC2_OTG=1), both blocks fire and produce conflicting dtoverlay lines:
dtoverlay=dwc2,dr_mode=peripheral
dtoverlay=dwc2,dr_mode=host
According to the linux doc Documentation/devicetree/bindings/usb/usb-drd.yaml. It's an enum, only one dr_mode can be active, so the result is undefined.
Suggested fix:
Replace the three independent if blocks with an elif chain to make mutual exclusivity explicit: