Author Topic: Is USB control transfers used for anything else ?  (Read 1101 times)

0 Members and 2 Guests are viewing this topic.

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 460
  • Country: ch
Is USB control transfers used for anything else ?
« on: December 01, 2023, 02:13:07 pm »
For a request-response type communication (not time sensitive etc.), I guess both control and bulk transfers can be used. I wonder if control transfers are used in actual device implementations other than the default endpoint 0, or always bulk is used since control does not probably bring something extra ?
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11474
  • Country: us
    • Personal site
Re: Is USB control transfers used for anything else ?
« Reply #1 on: December 01, 2023, 04:29:35 pm »
Control transfers can only be issues to the EP0. There is no way to send them over any other endpoint and non-0 endpoints should not have control type.

But the data transfer over the control endpoint is used a lot. For example DFU (firmware update) class does all its communications over the control endpoint. This allows for very small bootloaders, since all the descriptors are small and the whole bunch of code related to normal communications can be removed.
« Last Edit: December 01, 2023, 04:31:16 pm by ataradov »
Alex
 

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 460
  • Country: ch
Re: Is USB control transfers used for anything else ?
« Reply #2 on: December 01, 2023, 04:42:21 pm »
Thanks for mentioning DFU, I didnt know that.

I believe control transfers do not need to be ep0 only, I mean at least spec does not prevent it. But not sure if it is used, how it is used etc.

I think what you mean is standard requests only work in ep0, but a control transfer type ep (not sure about 0 but anything else possible) can be used for normal data transfers as well, and maybe that is what you mean these need ZLP like other transfer types bulk etc.
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11474
  • Country: us
    • Personal site
Re: Is USB control transfers used for anything else ?
« Reply #3 on: December 01, 2023, 04:53:00 pm »
I don't see any specific restrictions on setting the endpoint type to Control for a non-zero endpoint, but I don't know if that will ever work in practice. I think most implementations assume that there will only be one control endpoint, and is is endpoint 0.

EP0 itself can be used for general data transfer like any other endpoint.
Alex
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11474
  • Country: us
    • Personal site
Re: Is USB control transfers used for anything else ?
« Reply #4 on: December 01, 2023, 05:03:38 pm »
Ok, the spec mentions in one place "For all other control endpoints.....", so I guess it is possible to have control endpoint at non-0 index. This would be pretty bizarre, I have never seen this is done and I assume you will run int all sorts of issues with support for this. Pretty much everyone assumes EP0 and only EP0 to be a control endpoint.

Even looking at the libusb API,  libusb_control_transfer(), which sends the SETUP-type transfer, does not take endpoint index, so you can only issue SETUP transactions to the ep0.

And I don't think there is a way to generate just an IN/OUT transfer to the control endpoint not as a part of the data stage of the SETUP transfer. All APIs infer the direction from the endpoint index, but the control endpoint uses the same index for both directions and the actual direction is derived from the SETUP packet.

So, it looks like even arbitrary exchange is not that easy. And this is why everyone (including DFU) uses SETUP transfers with vendor or class request types. You still get arbitrary payloads, just as a part of the data stage of the SETUP transfer. Plus you get a nice way to send additional request parameters in the fields of the setup packet.
« Last Edit: December 01, 2023, 05:25:23 pm by ataradov »
Alex
 

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 460
  • Country: ch
Re: Is USB control transfers used for anything else ?
« Reply #5 on: December 01, 2023, 07:48:30 pm »
Good point about libusb.

So the control transfer uses so called a message pipe, whereas others use stream pipe. Message pipe implies a structure and my understanding and guess was that this structure is this setup-data-status thing. So I think any endpoint can be control transfer type (I understand it might be very uncommon and unsupported) but then they still have to use the same structure. That is actually why I asked if there is a point using this because something with similar functionality for request reply type communication can be done with bulk and I guess it is more easy to use just plain IN and OUT and app defined messages.
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11474
  • Country: us
    • Personal site
Re: Is USB control transfers used for anything else ?
« Reply #6 on: December 01, 2023, 07:53:12 pm »
Yes, this seems to be the case.

And yes, for sure use plain bulk endpoints for non-0 index. I would expect a nightmare of incompatibilities if you try to use control endpoint on a non-0 index.

There is nothing wrong with using EP0 for general command transfer, I do it all the time. Sure, it comes as a SETUP and then IN /OUT combo, but that's not a big deal. And again, you get the added benefit of the fields in the setup data. So if you are transferring simple commands, you may not need any data payload at all.
Alex
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14891
  • Country: fr
Re: Is USB control transfers used for anything else ?
« Reply #7 on: December 01, 2023, 11:21:04 pm »
I'm sure the USB controllers of many, if not most, MCUs do not support control endpoints other than 0, so you may not have a lot of luck even trying that in practice, unless you implement your own controller or find a chip that can do that.

Note that control endpoints can only transfer 64 bytes (IIRC), so if you're using that for all your data transfers on anything > USB LS or FS, you're not going to get fantastic throughput. But I guess the typical use cases do not require much, like DFU.
 

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 460
  • Country: ch
Re: Is USB control transfers used for anything else ?
« Reply #8 on: December 02, 2023, 04:35:57 am »
I'm sure the USB controllers of many, if not most, MCUs do not support control endpoints other than 0, so you may not have a lot of luck even trying that in practice, unless you implement your own controller or find a chip that can do that.

Note that control endpoints can only transfer 64 bytes (IIRC), so if you're using that for all your data transfers on anything > USB LS or FS, you're not going to get fantastic throughput. But I guess the typical use cases do not require much, like DFU.

OK I understand, I should not think about non-ep0 control transfers then.

BULK in FS is also limited to 64 bytes, but I got the point.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf