Welcome, Guest

Author Topic: usb gadget devices  (Read 5357 times)

lambda

  • Full Member
  • ***
  • Posts: 180
  • Karma: +21/-0
    • Support my work
usb gadget devices
« on: March 03, 2015, 02:19:46 PM »
Hi,

has anybody got usb gadget devices running on the imx233-olinuxino-mini?

I have the modules for ethernet gadget loaded and I see the usb0 device
with ifconfig (independent of other drivers loaded/running actually), but
I don't get the device enumerated by any host.

I'd expect that if I removed all USB-disks, USB-mice etc., then the USB
hardware would switch from host mode to device mode and the gadget device
would start working. But my PC (running linux) simple doesn't enumerate it
at all.

Anybody knows how to test if an USB cable actually has the connections right
for this kind of thing to work?

thanks for any hints,
Harald

mbergmann

  • Jr. Member
  • **
  • Posts: 61
  • Karma: +3/-0
    • My blog
Re: usb gadget devices
« Reply #1 on: March 03, 2015, 02:38:35 PM »
Hi Harald,

it's not working. The mini board uses a GL850G USB Hub and therefore can't be set up as mass storage device.

Even if you take a hardware without Hub connected to the SoC it will probably not work. My own board is capable working as mass storage with my own software, but if I use the Linux mass storage gadget driver the system crashes.

I get:

Code: [Select]
[   14.150000] ci_hdrc ci_hdrc.0: ChipIdea HDRC found, lpm: 0; cap: c4b80100 op: c4b80140
[   14.150000] ci_hdrc ci_hdrc.0: It is OTG capable controller
[   14.150000] ci_hdrc ci_hdrc.0: doesn't support host
[   66.820000] udc ci_hdrc.0: registering UDC driver [g_mass_storage]
[   66.820000] g_mass_storage gadget: adding config #1 'Linux File-Backed Storage'/bf040ee0
[   66.820000]  lun0: open backing file: ./backing_file
[   66.840000] g_mass_storage gadget: Mass Storage Function, version: 2009/09/11
[   66.850000] g_mass_storage gadget: Number of LUNs=1
[   66.880000]  lun0: LUN: file: /root/backing_file
[   66.890000] g_mass_storage gadget: I/O thread pid: 115
[   66.900000] g_mass_storage gadget: adding 'Mass Storage Function'/c3bc7b80 to config 'Linux File-Backed Storage'/bf040ee0
[   66.900000] g_mass_storage gadget: cfg 1/bf040ee0 speeds: high full
[   66.900000] g_mass_storage gadget:   interface 0 = Mass Storage Function/c3bc7b80
[   66.900000] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[   66.910000] g_mass_storage gadget: userspace failed to provide iSerialNumber
[   66.920000] g_mass_storage gadget: g_mass_storage ready

and then the board hangs ....

Btw. All the Olimex boards always provide 5V on the USB port to power the devices. On my board I use a GPIO to switch this 5V on or off considering the controller mode (host or device). It's not he best idea if both sides (host and device) provide 5V.

If someone got the mass storage gadget mode working it would be very interesting to know how to set up the system.

Regards

Mike
« Last Edit: March 03, 2015, 02:40:10 PM by mbergmann »

lambda

  • Full Member
  • ***
  • Posts: 180
  • Karma: +21/-0
    • Support my work
Re: usb gadget devices
« Reply #2 on: March 03, 2015, 10:03:25 PM »
Hi Mike!

it's not working. The mini board uses a GL850G USB Hub and therefore can't be set up as mass storage device.

Thanks, that explains. You happen to know if an USB Hub also is present on Micro or Nano?

I guess this means that there also is no hope to get recovery boot mode via USB to work?
(This would be valuable information, because then there is no reason not to blow the efuses
and make booting via SD-Card the only option.)

Quote
Even if you take a hardware without Hub connected to the SoC it will probably not work. My own board is capable working as mass storage with my own software, but if I use the Linux mass storage gadget driver the system crashes.

Well I tried the ethernet gadget, which at least did not crash my system. Maybe you could try some other
gadgets too to see if the problem is with the gadget or the USB subsystem.

Quote
I get:

Code: [Select]
[   14.150000] ci_hdrc ci_hdrc.0: ChipIdea HDRC found, lpm: 0; cap: c4b80100 op: c4b80140
[   14.150000] ci_hdrc ci_hdrc.0: It is OTG capable controller
[   14.150000] ci_hdrc ci_hdrc.0: doesn't support host
[   66.820000] udc ci_hdrc.0: registering UDC driver [g_mass_storage]
[   66.820000] g_mass_storage gadget: adding config #1 'Linux File-Backed Storage'/bf040ee0
[   66.820000]  lun0: open backing file: ./backing_file
[   66.840000] g_mass_storage gadget: Mass Storage Function, version: 2009/09/11
[   66.850000] g_mass_storage gadget: Number of LUNs=1
[   66.880000]  lun0: LUN: file: /root/backing_file
[   66.890000] g_mass_storage gadget: I/O thread pid: 115
[   66.900000] g_mass_storage gadget: adding 'Mass Storage Function'/c3bc7b80 to config 'Linux File-Backed Storage'/bf040ee0
[   66.900000] g_mass_storage gadget: cfg 1/bf040ee0 speeds: high full
[   66.900000] g_mass_storage gadget:   interface 0 = Mass Storage Function/c3bc7b80
[   66.900000] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[   66.910000] g_mass_storage gadget: userspace failed to provide iSerialNumber
[   66.920000] g_mass_storage gadget: g_mass_storage ready

and then the board hangs ....

Which kernel version?

Quote
If someone got the mass storage gadget mode working it would be very interesting to know how to set up the system.

If its possible to use gadgets on nano, I will try them eventually.

Thanks,
Harald

mbergmann

  • Jr. Member
  • **
  • Posts: 61
  • Karma: +3/-0
    • My blog
Re: usb gadget devices
« Reply #3 on: March 04, 2015, 10:02:57 AM »
Hi Harald,


Thanks, that explains. You happen to know if an USB Hub also is present on Micro or Nano?

I guess this means that there also is no hope to get recovery boot mode via USB to work?

The OLinuxIno Maxi has an combined Ethernet Port / USB Hub IC onboard (LAN9512-JZX).

The OLinuxIno Micro and Nano have no Hub, I never tried to make the Nano a USB device. Maybe you have to mess with the ID Pin (4) of Nanos USB Port to get it working. As said before you have to take care of the 5V HOST_PWR on pin 1.

For the boards with Hub: Yes, there is no change for the recovery mode.

Quote
Which kernel version?

I'm using 3.12.0-00006 (build myself)

Thanks

Mike

lambda

  • Full Member
  • ***
  • Posts: 180
  • Karma: +21/-0
    • Support my work
Re: usb gadget devices
« Reply #4 on: March 04, 2015, 01:21:25 PM »
Thanks for the information. I'll blow the eFuses then - they already got into my way a number of times.

I did my usb gadget experiments on 3.14.32 and 3.19.

Thanks,
Harald

lambda

  • Full Member
  • ***
  • Posts: 180
  • Karma: +21/-0
    • Support my work
Re: usb gadget devices
« Reply #5 on: April 06, 2015, 08:37:04 PM »
mbermann wrote some time ago:
Quote
The OLinuxIno Micro and Nano have no Hub, I never tried to make the Nano a USB device. Maybe you have to mess with the ID Pin (4) of Nanos USB Port to get it working. As said before you have to take care of the 5V HOST_PWR on pin 1.

Ok, finally hat the time to power up my NANO and in dmesg output I get:
[  688.810000] ci_hdrc ci_hdrc.0: EHCI Host Controller
[  688.820000] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[  688.840000] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[  688.850000] hub 1-0:1.0: USB hub found
[  688.850000] hub 1-0:1.0: 1 port detected

Now I am confused: Where is this hub coming from? The above is with a plain NANO,
5V supply and debug UART.

AFAIKS from the schematic the processor pins are directly connected to the USB
connector on the NANO. How can I dig into this futher?

(Sorry for all the questions. I'm quite experienced with Linux but never cared
much about USB before ...)

TIA,
Harald

swahren

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +7/-0
Re: usb gadget devices
« Reply #6 on: April 06, 2015, 08:59:18 PM »
Hi Harald,

according to your thread about "switching LED disables USB" you could try to set "dr_mode" to "peripheral" for the NANO:

http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/usb/ci-hdrc-imx.txt

Best regards
Stefan

lambda

  • Full Member
  • ***
  • Posts: 180
  • Karma: +21/-0
    • Support my work
Re: usb gadget devices
« Reply #7 on: April 07, 2015, 06:44:39 PM »
Hi Stefan!

I tried switching to peripheral mode with the USB_ID pin (i.e. enabling the
green LED ...) this worked at least to the point where the USB driver
switched off the vbus0. But you are right, forcing peripheral mode in DT is
a good next step.

As for my question above: I compared the dmesg output from NANO with MINI and
there I get two hubs reported:
[    0.380000] usbcore: registered new interface driver hub
[    1.770000] hub 1-0:1.0: USB hub found
[    1.780000] hub 1-0:1.0: 1 port detected
[    2.250000] hub 1-1:1.0: USB hub found
[    2.270000] hub 1-1:1.0: 4 ports detected

so looks like Linux thinks every host controller is a one port hub or something
along that lines. I need to find some good documentation to read up about that
whole thing ...

Thanks for your help so far,
Harald

JohnS

  • Hero Member
  • *****
  • Posts: 1720
  • Karma: +33/-48
Re: usb gadget devices
« Reply #8 on: April 07, 2015, 07:04:20 PM »
Maybe the on-chip USB is one and on the MINI the GL850 is the other hub.

John