On Tue, Jan 05, 2021 at 02:02:16AM +0100, Tomasz Grobelny wrote: > Hi all, > > I am trying to implement Android Open Accessory Protocol which is a > base for Android Auto Protocol. I am using Odroid N2 working in gadget > mode and trying to send data to car's headunit. > > The problem I am facing now is that for some headunits it works, for > some it doesn't. It seems there is some difference in what happens > immediately after the host tries to switch device to accessory mode by > sending control commands 51, 52 and 53. The initial part in all cases > (all headunits I have access to) works just fine, but after it > completes my Odroid gadget should be reinitialized on the USB bus. On > hosts on which it works (my PC and VW headunit) the device gets new > address like this: > > [ 33.491312] Mass Storage Function, version: 2009/09/11 > [ 33.491322] LUN: removable file: (no medium) > [ 33.504716] file system registered > [ 33.506279] read descriptors > [ 33.506290] read strings > [ 33.510164] dwc2 ff400000.usb: bound driver configfs-gadget > [ 33.678710] dwc2 ff400000.usb: new device is high-speed > [ 33.750089] dwc2 ff400000.usb: new device is high-speed > [ 33.806366] dwc2 ff400000.usb: new address 4 > [ 37.899601] ffs_data_put(): freeing > [ 37.899862] unloading > [ 38.942619] file system registered > [ 38.943003] read descriptors > [ 38.943009] read strings > [ 38.946561] dwc2 ff400000.usb: bound driver configfs-gadget > [ 39.310762] dwc2 ff400000.usb: new device is high-speed > [ 39.381890] dwc2 ff400000.usb: new device is high-speed > [ 39.438056] dwc2 ff400000.usb: new address 5 > > On Fiat's headunit I get the same address for both phases: > [ 33.773387] Mass Storage Function, version: 2009/09/11 > [ 33.773397] LUN: removable file: (no medium) > [ 33.784054] file system registered > [ 33.792335] read descriptors > [ 33.792389] read strings > [ 33.796349] dwc2 ff400000.usb: bound driver configfs-gadget > [ 34.023544] dwc2 ff400000.usb: new device is high-speed > [ 34.131592] dwc2 ff400000.usb: new device is high-speed > [ 34.194740] dwc2 ff400000.usb: new address 3 > [ 34.353478] ffs_data_put(): freeing > [ 34.353825] unloading > [ 35.392723] file system registered > [ 35.393450] read descriptors > [ 35.393459] read strings > [ 35.403955] dwc2 ff400000.usb: bound driver configfs-gadget > [ 37.119299] dwc2 ff400000.usb: new device is high-speed > [ 37.227341] dwc2 ff400000.usb: new device is high-speed > [ 37.290497] dwc2 ff400000.usb: new address 3 > > Any idea why this might be the case? Can I somehow enforce that the > device reintroduces itself on the bus and gets new address? Can I > somehow debug what happens when my device is connected as gadget (eg. > see control messages for device/configuration/string descriptors)? Why does it matter what USB "address" your device gets? That's a random number that nothing should care about as the USB spec allows it to be reused if the host controller wants to. What requires a "different" address each time? Shouldn't that userspace bug be fixed instead? thanks, greg k-h