agherzan / meta-raspberrypi

Yocto/OE BSP layer for the Raspberry Pi boards
https://www.yoctoproject.org/
MIT License
540 stars 414 forks source link

USB Peripheral (Gadget) mode is always forced to host on boot #960

Closed maurosanjo closed 2 years ago

maurosanjo commented 2 years ago

Description Using honister I built and image for Raspberry Pi Zero 2 W 64bits adding dwc2 overlay and config ENABLE_DWC2_PERIPHERAL, and when booting dmesg states "Configuration mismatch. dr_mode forced to host"

Steps to reproduce the issue:

  1. Build poky-honister for raspberrypi0-2w-64 with dwc2 overlay
  2. boot
  3. RNDIS does not come up, host mode is forced, unable to up usb0 network interface

Describe the results you received:

/var/log/dmesg

[    2.090857] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    2.091266] dwc_otg: FIQ enabled
[    2.091281] dwc_otg: NAK holdoff 
[    2.091295] dwc_otg: FIQ split-transaction FSM enabled
[    2.091315] Module dwc_common_port init
[    2.092328] dwc2 3f980000.usb: supply vusb_d not found, using dummy regulator
[    2.092591] dwc2 3f980000.usb: supply vusb_a not found, using dummy regulator
[    2.093333] dwc2 3f980000.usb: Configuration mismatch. dr_mode forced to host
[    2.144442] dwc2 3f980000.usb: DWC OTG Controller
[    2.144520] dwc2 3f980000.usb: new USB bus registered, assigned bus number 1
[    2.144589] dwc2 3f980000.usb: irq 51, io mem 0x3f980000
[    2.145151] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.10
[    2.145172] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.145190] usb usb1: Product: DWC OTG Controller
[    2.145208] usb usb1: Manufacturer: Linux 5.10.78-v8 dwc2_hsotg

config.txt

# Enable UART
enable_uart=1
# Enable VC4 Graphics
dtoverlay=vc4-fkms-v3d
# Enable Sony RaspberryPi Camera(imx219)
dtoverlay=imx219
# Enable USB peripheral mode
dtoverlay=dwc2,dr_mode=peripheral
# Disable bluetooth to restore UART0/ttyAMA0 to GPIO 13,14
dtoverlay=disable-bt
# Drives a GPIO high on poweroff
dtoverlay=gpio-poweroff,active_low=0,gpiopin=18

# have a properly sized image
disable_overscan=1
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
maurosanjo commented 2 years ago

g_ether not being loaded was the problem, to solve I had to change some kernel configs:

CONFIG_USB_GADGET=y
CONFIG_USB_ETH=y
CONFIG_USB_ETH_RNDIS=y
CONFIG_INET=y