On Sun, 17 Apr 2022 at 10:45, Sergey Nazaryev <ser...@coolautomation.com> wrote:
>
> > So I think the right place to call usb_gadget_initialize is probably
> > before registering the acm gadget function into acm_stdio_start(). Can
> > you try this? and submit a follow_up fix patch if working?
>
> It's required for `usb_gadget_initialize` to provide a "USB
> controller index" as an argument. It's pretty obvious how to do it in
> "interactive world" (e.g. to ask user for this number via CLI, like
> it was in commands mentioned in my previous message) but in our case
> we need to provide this number in non-interactive manner.
>
> There is not an elegant solution with hardcoding '0' as a controller
> index like it was done in `ether` gadget [1], but it seems that it
> was a temporary fix ("This is a preparatory work for DM support for
> UDC drivers") that occasionaly became a permament solution.
>
> So, that's why I suggested to add a new subcommand to `usb` for OTG
> initialization: in my opinion, it's better to require an explicit
> call of something like `usb otgstart 0` than hardcoding a '0' into
> the code. One more option is to add a new environment variable to
> explictly specify a controller index, and read this variable from all
> places when it requires.
>
> P.S. I already put `usb_gadget_intiialize(0)` to my board code, and
> ACM gadget started working; so the remaining problem is only to
> decide where is the best place for this call.

Yes, but whatever the solution, we also need to know the controller
index from gadget driver, since we need it for
usb_gadget_handle_interrupts(index). So an env or global variable
would be at least a good start.

Regards,
Loic

>
> [1]: 
> https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/usb/gadget/ether.c#L2355

Reply via email to