USB init before using usb_serial_acm gadget?
Sergey Nazaryev
sergey at coolautomation.com
Thu Apr 14 20:37:32 CEST 2022
Hi!
As I can see, recently [1] the implementation of USB ACM gadget has
been merged into U-boot master. I tried to use it but the problem is
that running `setenv stdout usbacm` on my board based on STM32MP157
leads to errors below:
STM32MP> setenv stdout usbacm
couldn't find an available UDC
g_dnl_register: failed!, error: -19
## Error inserting "stdout" variable, errno=22
After some research I've found that USB OTG controller must be
initialized somehow before we can actually start using any gadget.
For instance, on my STM32MP board `dwc2_udc_otg_probe` should be
called. My research shows that `usb_gadget_initalize` is responsible
for it; so, for this reason, there are explicit calls of
`usb_gadget_initialize` (e.g. usb_dnl_dfu [2], usb_dnl_sdp [3])
before actual usage of any gadget.
However, unlike all other gadgets, usb_serial_acm code and code that
uses it don't call usb_gadget_initialize at all. Okay, I understand
that usb_serial_acm shouldn't initialize USB controllers by itself,
but it's still unclear who must be responsible for it.
So, my main question is: what's the best place for
`usb_gadget_initialize` call? Should I put it to board-specific code
(board/vendor/xxx.c) or maybe it's better to put `usb_gadget_initialize`
into new `usb` subcommand (`usb otgstart` or something like that) and
call it before `setenv stdout usbacm`?
Thank you in advance,
Sergey
[1]: https://source.denx.de/u-boot/u-boot/-/commit/fc2b399ac03b91339a1cb1bfd4d1a9ca87fe95c6
[2]: https://source.denx.de/u-boot/u-boot/-/blob/master/common/dfu.c#L28
[3]: https://source.denx.de/u-boot/u-boot/-/blob/master/cmd/usb_gadget_sdp.c#L24
More information about the U-Boot
mailing list