USB device mode on a Micro

Started by whophlungpoo, October 16, 2012, 10:53:40 PM

Previous topic - Next topic

whophlungpoo

I've been attempting to get the g_ether gadget functioning on a Micro.  I made a USB-A to USB-A cable with the +5V line disconnected.  Bitburner sees the device when I power it up without the boot uSD card installed.  All is happy.

I have recompiled the kernel with the host mode support turned off and the g_ether gadget as a module.

when I execute: modprobe g_ether I get the error: No Such Device.

Looking at the kernel config, there is a section: USB Peripheral Controller.

Do I need to find/create a USB Peripheral controller driver for the Micro to function in device mode to make use of the g_ether gadget?


ngcoders

I would also be interested in this , we also tried to make it a gadget . But it does not seem to work. Could not find anyone doing this either.

whophlungpoo

As far as I can tell, this should be possible. I'm still hacking away on the kernel to see if'n i can make this go.....

dpwhittaker

My solution is to use one of these:

http://www.aliexpress.com/item/Mini-USB-To-TTL-COM-Converter-Module-build-in-CP2102-OT859/493797154.html

It basically integrates the USB->UART module into my system, so I can use a standard USB cable to plug into the UART, then I can watch the tty for messages with my own protocol, set up a getty, or run PPP over it.  I'll probably use the AUART on the UEXT pins for a 1MBit connection speed.  All in all, it should provide all the capabilities I need to communicate with the board.  I need USB host for another purpose anyway, so I would need another port anyway.  Just something to think about before you go reinvent the wheel.

whophlungpoo

That's neat, but not fast enough.  I want to build a cluster out of a Maxi (master node) and a bunch of micro's (slave nodes).  In theory, I could setup the micros as USB devices and the Maxi as a Host device and use a large USB hub to tie them all together.  Then i could use the USB Ethernet gadget on the micros to communicate with the maxi and build an arm cluster easily and most importantly, cheaply :)

nidalpres

I'm also working on getting micro to act as usb peripheral using gadget drivers.
So far no success, also getting error "No such device".
I have recompiled kernel couple of times, however:
- EHCI drivers for USB controller are enabled, compiled and working ok by default
- it doesn't matter if host mode is enabled or not
- it seems this message "No such device" (errno is ENODEV) has something to do with driver not being able to find whatever node it is looking for under either /dev or /proc

There is /dev/usbdev1.1 node and right now I can't tell what it is since I didn't built usbutils into rootfs (ups!). Will do on next run, it is building right now.

Also, all modules required by i.e. g_ether, are already "loaded" in a sense that they are all built into kernel by default and thus available.

If anyone makes any progress, please report. I will do so as soon as I have anything working.

@whophlungpoo:
ARM cluster? You are crazy  ;D and go for it!

dpwhittaker

Quote from: whophlungpoo on November 01, 2012, 04:52:14 PM
That's neat, but not fast enough.  I want to build a cluster out of a Maxi (master node) and a bunch of micro's (slave nodes).  In theory, I could setup the micros as USB devices and the Maxi as a Host device how and use a large USB hub to tie them all together.  Then i could use the USB Ethernet gadget on the micros to communicate with the maxi and build an arm cluster easily and most importantly, cheaply :)

Not to stomp on your fun or anything, but I get the feeling that USB hubs handle collisions much less gracefully than ethernet switches, perhaps only by association with ethernet hubs.  I think the USB hub would quickly become the limiting factor in the size of your cluster... which since you  are dealing with nodes costing 30 EUR, I expect you are hoping for a big cluster.  If not the hub, then the absolute maximum for USB is what, 480mbit, and every single packet has to flow through the host maxi at some point, right?  Why not buy a $5 usb ethernet dongle (be careful which one you get) and plug them all into a decent switch?  Switches can get expensive as they get more ports, but its better than your cluster performance topping out at 10 nodes due to communication bottlenecks.

nidalpres

Had to recompile 2.6.35.3 kernel from LTIB without USB host support for USB gadget to work on olinuxino-micro.
Even if I chose USB host support to be built as a module, kernel would still load drivers at boot time and configure USB controller as a host. This probably wouldn't allow USB gadget drivers to set controller into device mode later on.

Anyway, usb gadget mode works now with still some quirks:
- as soon as I plug in USB cable into connector on the board, micro reboots. After that it works fine.
- my PC ubuntu installation after some time drops ip configuration of usb0 interface and I have to configure it again using ifconfig. Once I configure usb0 on olinuxino with ifconfig, it stays configured with its IP address.

First issue is not a big deal, but I will have to look at the second one.

I have also connected olinuxino as a USB ehernet gadget to WindowsXP running in VirtualBox and it installed RNDIS drivers for it, said it is 425Mbit speed interface and started looking up the IP address on that new interface using DHCP. dmesg on olinuxino shows WinXP bombarding little usb gadget with rndis packets, to no avail  8)

Average ping from olinuxino to WinXP inside VirtualBox and other way around is cca 14ms, and ping between olinuxino and my host ubutnu pc is cca 0.5ms.

Bottom line:
- compile linux kernel without USB host support
- make sure you have selected USB gadget support
- make sure in kernel config menu, under USB gadget, that you have selected drivers for gadgets you intend to use

That should work, at least it did in my case.

Happy hacking,
NP

nidalpres

Problem with Ubuntu dropping IP configuration for usb0 network interface was that by default it was configured to use DHCP. In top right corner on desktop there's network menu in which you can find "Edit connections..." entry and there you can enter fixed IP address for usb0 wired network interface. After that everything works fine and without interruptions...

whophlungpoo

Awesome nidalpres!!!, I will have another go at it.  One thing, are you disconnecting the power line of the USB when you plug your micro into the host?  That might have something to do with it rebooting.

nidalpres

I just use A-A non-standard USB cable to directly connect micro to the host PC.
I guess it might have something to do with brownout reset. Once connected to host PC micro board works fine so this is minor detail for now.
One thing I might try is to first load (modprobe) some USB gadget driver (that might disable USB power line on micro board) and then plug micro to host pc.