USB device mode
#1
Hi,

Has anybody successfully got the RockPro64 work as USB device towards the host PC? We've followed couple of instructions how to enable USB ECM gadget but so far no luck, device is not recognized by the PC.

The dts is changed to force the usb0 as peripheral


Code:
usb0 {
  status = "okay";
  ...
  dwc3@fe800000 {
      ....
      dr_mode = "peripheral";

Gadget device is correctly configured 


Code:
root@rockpro64:/sys/kernel/config/usb_gadget/g1# find .
.
./os_desc
./os_desc/qw_sign
./os_desc/b_vendor_code
./os_desc/use
./strings
./strings/0x409
./strings/0x409/serialnumber
./strings/0x409/product
./strings/0x409/manufacturer
./configs
./configs/c.1
./configs/c.1/ecm.0
./configs/c.1/strings
./configs/c.1/bmAttributes
./configs/c.1/MaxPower
./functions
./functions/ecm.0
./functions/ecm.0/ifname
./functions/ecm.0/qmult
./functions/ecm.0/host_addr
./functions/ecm.0/dev_addr
./UDC
./bcdUSB
./bcdDevice
./idProduct
./idVendor
./bMaxPacketSize0
./bDeviceProtocol
./bDeviceSubClass
./bDeviceClass
root@rockpro64:/sys/kernel/config/usb_gadget/g1# cat UDC 
fe800000.dwc3

But still no luck. 
dmesg shows this so at least something is working: 

Code:
[ 3691.636525] using random self ethernet address
[ 3691.636544] using random host ethernet address
[ 3691.651025] usb0: HOST MAC b6:35:e2:c4:92:c2
[ 3691.651096] usb0: MAC 8a:57:3c:87:d7:dd


Any suggestions what might be wrong?

Thanks!
#2
Answering to myself
We got it working.. sort of.
Procedure:
1.
fe800000.dwc3 must have dr_mode "otg" on boot-up

2. 
Apply overlay to enable "peripheral" mode

Code:
enable_dtoverlay usb0_dwc3_peripheral usb0/dwc3@fe800000 okay  'dr_mode="peripheral"'

3.
After applying the overlay we have to try to unbind the device. 

Code:
echo fe800000.dwc3 > /sys/bus/platform/drivers/dwc3/unbind

This does not work as advertised and will trigger a kernel oops. (Unable to handle kernel NULL pointer dereference at virtual address 000000d0)


Code:
[  426.994619] 79c0: 0000000000000000 0000000000000000
[  426.994643] [<ffffff800825ee48>] sysfs_remove_group+0x24/0x98
[  426.994659] [<ffffff80087c9d4c>] usb_remove_hcd+0x5c/0x1e8
[  426.994673] [<ffffff800882cb58>] xhci_plat_remove+0x4c/0xac
[  426.994687] [<ffffff800870bf88>] platform_drv_remove+0x2c/0x54
[  426.994703] [<ffffff800870a39c>] __device_release_driver+0x88/0xf8
[  426.994717] [<ffffff800870a438>] device_release_driver+0x2c/0x40
[  426.994730] [<ffffff80087092b0>] bus_remove_device+0x104/0x138
[  426.994743] [<ffffff8008706120>] device_del+0x130/0x1d8
[  426.994755] [<ffffff800870c5a4>] platform_device_del+0x28/0x8c
[  426.994766] [<ffffff800870c628>] platform_device_unregister+0x20/0x34
[  426.994782] [<ffffff80087dfbf8>] dwc3_host_exit+0x60/0x6c
[  426.994795] [<ffffff80087dca84>] dwc3_remove+0xe4/0xf0
[  426.994806] [<ffffff800870bf88>] platform_drv_remove+0x2c/0x54
[  426.994820] [<ffffff800870a39c>] __device_release_driver+0x88/0xf8
[  426.994834] [<ffffff800870a438>] device_release_driver+0x2c/0x40
[  426.994847] [<ffffff80087087e4>] unbind_store+0x68/0xa4
[  426.994859] [<ffffff8008707afc>] drv_attr_store+0x40/0x58
[  426.994873] [<ffffff800825db88>] sysfs_kf_write+0x54/0x74
[  426.994886] [<ffffff800825cbf0>] kernfs_fop_write+0x120/0x17c
[  426.994901] [<ffffff80081e56a0>] __vfs_write+0x48/0xe4
[  426.994913] [<ffffff80081e6064>] vfs_write+0xa8/0x17c
[  426.994925] [<ffffff80081e6a88>] SyS_write+0x54/0x98
[  426.994939] [<ffffff8008082f30>] el0_svc_naked+0x24/0x28
[  426.994955] Code: aa0003f5 aa1e03e0 d503201f f9400281 (f9401ab3)

4.
For some reason now it's possible to add a gadget and it will work correctly when USB is plugged to host. Without triggering kernel panic on the last step the device will remain dead.


Possibly Related Threads…
Thread Author Replies Views Last Post
  USB3 xhci-hcd in SuperSpeed mode swan 0 804 05-11-2023, 05:35 AM
Last Post: swan
  RockPro64 linux console video mode callegar 0 1,137 09-06-2022, 02:32 PM
Last Post: callegar
  Need help! Can't get device mode to work. scanboy 6 5,439 12-29-2021, 08:35 PM
Last Post: djonathan
  Using the PCIe slot of ROCKPro64 as EndPoint mode nonoriri 1 2,169 11-20-2021, 10:53 AM
Last Post: fire219
  slave mode on Rockpro64 Radhika.gabani 1 2,662 09-22-2021, 05:35 AM
Last Post: mahtew

Forum Jump:


Users browsing this thread: 1 Guest(s)