RE: Question: GadgetFS and EP0 'IN' traffic?

2017-09-21 Thread g4
Hello Alan.

> Plenty of things could affect it.  Without knowing more about your system, I 
> can't be more specific.  For example, what UDC 
> driver are you using?

Ah . It's an ancient (3.4.x*) sunxi_usb_hdc running on an AllWinner H3.

> And have you tried testing your program with the dummy-hcd driver?

Good point. Not yet.

> Do you get the correct values for the GADGETFS_SETUP event?

You mean post enumeration from host to device? Yes, I send some majik packets 
for proof of life. All good in that direction.

> What is the return value from the write() call where you send the vendor data?

As expected, the number of bytes written back to the endpoint. In this case 4. 

> If you want to add some debugging output to the kernel's gadgetfs driver, the 
> appropriate place would be inside epo_write() in 
> drivers/usb/gadget/legacy/inode.c.  The part following:

Ideal and once again extremely helpful. Thank you.

BR,

Jerry.

* We will move to mainline ASAP but this is a quick proof of concept and there 
is zero support in mainline for the essential AllWinner camera interface. 
That'll be the next task.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Question: GadgetFS and EP0 'IN' traffic?

2017-09-20 Thread Alan Stern
On Wed, 20 Sep 2017 g...@novadsp.com wrote:

> Hello and thanks
> 
> > Do you mean: Any control-IN data (device to host) never appears on the
> wire?  After all, you said that bulk reads and writes 
> > are fine.
> 
> Correct. Data sent via the bulk endpoint is visible. Data sent device to
> host on EP0 in response to my vendor commands is not. Now this is very weird
> as the host is obviously getting enough traffic on EP0 to acquire
> descriptors and strings. 

That data is sent internally by the gadgetfs driver, whereas the 
vendor-specific data is taken from your userspace driver.  That is 
likely the reason for the difference in behavior.

> I am mystified. Is there anything internally that might affect EP0 writes
> once setup/configuration is complete? 

Plenty of things could affect it.  Without knowing more about your 
system, I can't be more specific.  For example, what UDC driver are you 
using?

And have you tried testing your program with the dummy-hcd driver?

> Can you suggest any obvious places further down the stack where I can put
> some trace/debug code? This board is a PITA to run under a debugger.

Do you get the correct values for the GADGETFS_SETUP event?

What is the return value from the write() call where you send the 
vendor data?

If you want to add some debugging output to the kernel's gadgetfs 
driver, the appropriate place would be inside epo_write() in 
drivers/usb/gadget/legacy/inode.c.  The part following:

} else if (dev->state == STATE_DEV_SETUP) {

len = min_t(size_t, len, dev->setup_wLength);
if (dev->setup_in) {
retval = setup_req (dev->gadget->ep0, dev->req, len);

is where the data you write gets copied into the kernel and sent to the
UDC driver.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Question: GadgetFS and EP0 'IN' traffic?

2017-09-20 Thread g4
Hello and thanks

> Do you mean: Any control-IN data (device to host) never appears on the
wire?  After all, you said that bulk reads and writes 
> are fine.

Correct. Data sent via the bulk endpoint is visible. Data sent device to
host on EP0 in response to my vendor commands is not. Now this is very weird
as the host is obviously getting enough traffic on EP0 to acquire
descriptors and strings. 

I am mystified. Is there anything internally that might affect EP0 writes
once setup/configuration is complete? 

Can you suggest any obvious places further down the stack where I can put
some trace/debug code? This board is a PITA to run under a debugger.

> Yes, that is how it should work.  The data is supposed to appear on the
bus.

Yes, as expected.

> ep0 is represented by the original gadget file (/dev/gadget/"UDC name"): 

Ah, of course.

I appreciate your exceptionally prompt response. Many thanks.

Jerry.



--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Question: GadgetFS and EP0 'IN' traffic?

2017-09-20 Thread Alan Stern
On Wed, 20 Sep 2017 g...@novadsp.com wrote:

> I'm obviously missing something here but am not quite sure what. 
> 
> My usermode code* is set up to emulate an existing FX3 device. Bulk reads
> and writes are all fine as are vendor-specific commands that are host to
> device. However anything that is device to host never appears on the wire.

Do you mean: Any control-IN data (device to host) never appears on the 
wire?  After all, you said that bulk reads and writes are fine.

> The generic handler for IN vendor requests is simply writes 'length' bytes
> back on the file descriptor that represents EP0. USB packet sniffers show
> that data never gets out.

Yes, that is how it should work.  The data is supposed to appear on the 
bus.

> Does it need to ACK or clear anything first?

No.

> Incidentally is there any reason why EP0 itself does not appear in the
> /dev/gadget tree?

ep0 is represented by the original gadget file (/dev/gadget/"UDC
name"): the one you write at the start to set up the device and config
descriptors, and the one that you read to get events.  When you see
a GADGETFS_SETUP event for an IN request, you write the data to that 
file and it should get sent to the host.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Question: GadgetFS and EP0 'IN' traffic?

2017-09-20 Thread g4
I'm obviously missing something here but am not quite sure what. 

My usermode code* is set up to emulate an existing FX3 device. Bulk reads
and writes are all fine as are vendor-specific commands that are host to
device. However anything that is device to host never appears on the wire.
 
The generic handler for IN vendor requests is simply writes 'length' bytes
back on the file descriptor that represents EP0. USB packet sniffers show
that data never gets out.

Does it need to ACK or clear anything first?

Incidentally is there any reason why EP0 itself does not appear in the
/dev/gadget tree?

TAIA

Jerry

* based on the example here: http://www.linux-usb.org/gadget/usb.c


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html