07-02-2019, 05:49 AM
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
3.
After applying the overlay we have to try to unbind the device.
This does not work as advertised and will trigger a kernel oops. (Unable to handle kernel NULL pointer dereference at virtual address 000000d0)
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.
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.