PINE64
Need help! Can't get device mode to work. - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: ROCKPRO64 (https://forum.pine64.org/forumdisplay.php?fid=98)
+--- Forum: Linux on RockPro64 (https://forum.pine64.org/forumdisplay.php?fid=101)
+--- Thread: Need help! Can't get device mode to work. (/showthread.php?tid=15518)



Need help! Can't get device mode to work. - scanboy - 12-10-2021

Hi, 

I'm running Debian on rockpro64, I want to setup rndis when device is plug into a linux host. I have modified the device tree to have USB-c port as peripheral. I have also setup configfs according to a lot of posts on the net, but every time I plug it in, linux host would give this error:

[Dec10 14:40] usb 1-2: new full-speed USB device number 57 using xhci_hcd
[  +0.128029] usb 1-2: device descriptor read/64, error -71
[  +0.236017] usb 1-2: device descriptor read/64, error -71
[  +0.235946] usb 1-2: new full-speed USB device number 58 using xhci_hcd
[  +0.128047] usb 1-2: device descriptor read/64, error -71
[  +0.235999] usb 1-2: device descriptor read/64, error -71
[  +0.108108] usb usb1-port2: attempt power cycle
[  +0.411868] usb 1-2: new full-speed USB device number 59 using xhci_hcd
[  +0.000146] usb 1-2: Device not responding to setup address.
[  +0.207999] usb 1-2: Device not responding to setup address.
[  +0.207841] usb 1-2: device not accepting address 59, error -71
[  +0.127874] usb 1-2: new full-speed USB device number 60 using xhci_hcd
[  +0.000143] usb 1-2: Device not responding to setup address.
[  +0.208144] usb 1-2: Device not responding to setup address.
[  +0.207847] usb 1-2: device not accepting address 60, error -71
[  +0.000175] usb usb1-port2: unable to enumerate USB device


I have bind fe800000.usb to UDC in configfs, but seems like whatever I change in configfs won't affect the result, as if configfs has nothing to do with the usb port.

I found someone else also had similar issue in another post on this forum, but there is no detail whether he found a solution or what the solution was. 
Can anyone help?


RE: Need help! Can't get device mode to work. - djonathan - 12-14-2021

I was looking for similar info, and this looks relevant, specifically the steps at the end:

https://forum.pine64.org/showthread.php?tid=11523


RE: Need help! Can't get device mode to work. - scanboy - 12-14-2021

(12-14-2021, 12:08 AM)djonathan Wrote: I was looking for similar info, and this looks relevant, specifically the steps at the end:

https://forum.pine64.org/showthread.php?tid=11523

Thanks for the reply. That's the exact post I was referring to in my first post, but for the life of me, I just can't echo device to mode no matter what, it doesn't give me any error, but after doing that, I cat mode and it is still host. I can't seem to be able to change mode to device (using root). I don't know what I'm doing wrong. I can set USB-c to device mode via dtb modifiction, but that means the board is booting with mode set to device already. Is the solution actually need the board to boot in "host" mode and then set it to "device"?


RE: Need help! Can't get device mode to work. - djonathan - 12-15-2021

My /sys/class/udc is an empty directory.  Is your's populated?

I followed the configfs recipe here https://elinux.org/images/e/ef/USB_Gadget_Configfs_API_0.pdf, right up to the end where /sys/class/udc is expected to have content.

I also get a /var/log/syslog message that is related: udc-core: couldn't find an available UDC - added [g_ether] to list of pending drivers

And doing echo device > /sys/kernel/debug/fe800000.usb/mode   does not change the mode, which continues to have "host" value.

Looking in /boot/config-5.10.0-7-arm64, I see # CONFIG_USB_OTG is not set.

(12-14-2021, 12:08 AM)djonathan Wrote: I was looking for similar info, and this looks relevant, specifically the steps at the end:

https://forum.pine64.org/showthread.php?tid=11523

Thanks for the reply. That's the exact post I was referring to in my first post, but for the life of me, I just can't echo device to mode no matter what, it doesn't give me any error, but after doing that, I cat mode and it is still host. I can't seem to be able to change mode to device (using root). I don't know what I'm doing wrong. I can set USB-c to device mode via dtb modifiction, but that means the board is booting with mode set to device already. Is the solution actually need the board to boot in "host" mode and then set it to "device"?


RE: Need help! Can't get device mode to work. - djonathan - 12-29-2021

@scanboy , were you able to get the device to enumerate?

I am running a Debian 5.15 kernel that does not have USB_OTG or device-tree OVERLAY enabled.  The original device-tree has dr_mode="host", so:
  • on the  running system I edited and replaced the dtb so that dr_mode="peripheral"
  • I can set up the configfs  /sys/kernel/config/usb_gadget/g1/ with files according to recipes for enabling RNDIS
  • /sys/class/udc has content, so I no longer get the "could not find an available udc" complaint
  • modprobe what look like the right drivers, and I see the kernel message g_ether gadget: g_ether ready
  • ip address shows usb0


I am trying to connect to a Windows 10 PC, and I get USB device not recognized when I plug in the cable, and running usbview.exe I see the real problem is FailedEnumeration.

So I think we are at the same point: the rockpro64 gadget is not responding to enumeration requests.


RE: Need help! Can't get device mode to work. - scanboy - 12-29-2021

(12-29-2021, 04:47 PM)djonathan Wrote: @scanboy , were you able to get the device to enumerate?

I am running a Debian 5.15 kernel that does not have USB_OTG or device-tree OVERLAY enabled.  The original device-tree has dr_mode="host", so:
  • on the  running system I edited and replaced the dtb so that dr_mode="peripheral"
  • I can set up the configfs  /sys/kernel/config/usb_gadget/g1/ with files according to recipes for enabling RNDIS
  • /sys/class/udc has content, so I no longer get the "could not find an available udc" complaint
  • modprobe what look like the right drivers, and I see the kernel message g_ether gadget: g_ether ready
  • ip address shows usb0


I am trying to connect to a Windows 10 PC, and I get USB device not recognized when I plug in the cable, and running usbview.exe I see the real problem is FailedEnumeration.

So I think we are at the same point: the rockpro64 gadget is not responding to enumeration requests.

I was pretty much stuck at the same point you are, no matter what I changed in configfs, it didn't seemed to matter which made me think that dt overlay is necessary. I haven't had much time to mess with this lately, the last thing I did was trying to recompile the kernel to include dt overlay, but failed, haven't had time to look into it.


RE: Need help! Can't get device mode to work. - djonathan - 12-29-2021

I changed to an Armbian load because that kernel has CONFIG_USB_OTG=y, thinking that would let me toggle between host and device in /sys/kernel/debug/fe800000.usb/mode, but I the mode doesn't change.  No idea why...

So I took a step back and just wondered is the device-tree correct for OTG behavior... did a web search for device-tree otg, and got this hit:

https://wiki.st.com/stm32mpu/wiki/OTG_device_tree_configuration#DT_configuration_example_as_high-speed_OTG_in_Host_or_Peripheral_mode-2C_with_micro-B_or_Type-C_connector-2C_and_with_VBUS_and_ID_left_unconnected

All those additional OTG-related keywords... I'm getting a bad feeling that the rockpro64 device-tree needs a lot of work.  Scroll up to the pins stanzas -- I see nothing like that in the rockpro64 device-tree.

The stm32 is microprocessor, and they provide this level of documentation...   Where is something similar for the rk3399?