Emulate an USB HUB

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Maui
Posts: 2
Joined: Mon Sep 06, 2010 4:02 pm

Emulate an USB HUB

Post by Maui » Mon Sep 06, 2010 4:32 pm

Hi there...

I am currently trying to emulate an USB-Hub and connect/disconnect several other devices (which would have to be emulated aswell). So far I have been able to present the Hub to the host and get it to request port states. The thing I am currently confused about is emulating the connect/disconnect of devices to my emulated hub. Anyone round here ever done sth like that.

Any help would be greatly appreciated.

maui

yapoid
Posts: 3
Joined: Thu Sep 09, 2010 3:29 pm

Re: Emulate an USB HUB

Post by yapoid » Thu Sep 09, 2010 3:34 pm

Hi,
I'm also working on emulating an USB HUB. I got the USB HUB to be found by Linux. Here's my dmesg output:

Code: Select all

[33547.616587] usb 5-1: new low speed USB device using uhci_hcd and address 83
[33547.774569] usb 5-1: configuration #1 chosen from 1 choice
[33547.779024] hub 5-1:1.0: USB hub found
[33552.785401] hub 5-1:1.0: config failed, can't read hub descriptor (err -22)


As you can see, Linux can't get the USB HUB Descriptor. How did you get V-USB to answer with the USB HUB Descriptor?

I think we're both working on the same project, would you mind PMing me with some contact info (MSN, GTalk, IRC or something) so we can work on this together?

crazyc
Posts: 1
Joined: Fri Sep 10, 2010 12:51 am

Re: Emulate an USB HUB

Post by crazyc » Fri Sep 10, 2010 12:54 am

I'm working on the same thing. I have everything working (hub, port connect, long descriptor) except the timing. The hub endpoint 1 always gets stuck in a stall condition after port 1 is enumerated because it can't be reached while usbDeviceAddr is set to the port 1 address. I'm using an attiny85 with the internal oscillator.

yapoid
Posts: 3
Joined: Thu Sep 09, 2010 3:29 pm

Re: Emulate an USB HUB

Post by yapoid » Fri Sep 10, 2010 6:18 am

@crazyc did you need to patch something to get V-USB to answer the HUB descriptor? (second byte from wValue equals 0x29, AFAIK)

Are you guys working on a new code from scratch or just porting the existing AT90USB LUFA-based source code?

I'm working with an ATmega328p clocked with an external 20MHz crystal and trying to just port the existing source code.

p.s.: Since we're all working on the same thing, I think it would be wise if we join our efforts. We can setup a github repo or something.
Last edited by yapoid on Mon Sep 13, 2010 5:00 pm, edited 1 time in total.

sys4096
Posts: 2
Joined: Fri Sep 10, 2010 5:08 pm

Re: Emulate an USB HUB

Post by sys4096 » Fri Sep 10, 2010 5:09 pm

I have an Arduino Mega1280 and also trying to get it working. Did you build the hardware with the zener diodes ?

yapoid
Posts: 3
Joined: Thu Sep 09, 2010 3:29 pm

Re: Emulate an USB HUB

Post by yapoid » Fri Sep 10, 2010 7:59 pm

Yes. Two 3v6 diodes: one between D+ and GND, the other one between D- and GND. My microcontroller is running with 5V, powered by the USB port.

Melfice
Posts: 1
Joined: Sun Sep 19, 2010 10:55 pm

Re: Emulate an USB HUB

Post by Melfice » Sun Sep 19, 2010 10:59 pm

I have an ATmega64 and also trying to make this. Can anybody share their stuff, so it might be easier?

xen0
Posts: 1
Joined: Mon Sep 20, 2010 7:58 am

Re: Emulate an USB HUB

Post by xen0 » Mon Sep 20, 2010 8:03 am

I just patched up version on github. Search for a fork with vusb. It's working for the arduino mega, should be relatively simple to patch to work for other boards/chips.

sys4096
Posts: 2
Joined: Fri Sep 10, 2010 5:08 pm

Re: Emulate an USB HUB

Post by sys4096 » Wed Sep 22, 2010 3:03 pm

hey xen0,

Just tried your port and it works like a charm. Thanks a lot for your effort !

fake

Re: Emulate an USB HUB

Post by fake » Thu Sep 23, 2010 2:22 am

seems vusb does not support write value to usbDeviceAddr "Reg".

brian
Posts: 1
Joined: Wed Feb 09, 2011 9:38 pm

Re: Emulate an USB HUB

Post by brian » Wed Feb 09, 2011 10:38 pm

Is hub emulation example code available? Thanks.

Post Reply