Page 1 of 1

Weird VUSB Linux disconnect...

Posted: Fri Apr 09, 2010 3:01 pm
by klaute_
Hi,

i've got a interesting problem while connecting my AVR with VUSB to a ASRock mini PC (running ubuntu linux 9.4).
I'm using VUSB (20090822) as a hiddata device on a ATMega32-16PU (16MHz).

At first, this is my usbconfig.h. I've removed the unchanged default lines and device strings in this post...

Code: Select all

...
#define USB_CFG_IOPORTNAME      B
/* This is the port where the USB bus is
 * "B", the registers PORTB, PINB and DD
 */
#define USB_CFG_DMINUS_BIT      1
/* This is the bit number in USB_CFG_IOP
 * This may be any bit in the port.
 */
#define USB_CFG_DPLUS_BIT       2
...
#define USB_CFG_INTR_POLL_INTERVAL      200
/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
 * interval. The value is in milliseconds and must not be less than 10 ms for
 * low speed devices.
 */
#define USB_CFG_IS_SELF_POWERED         1
/* Define this to 1 if the device has its own power supply. Set it to 0 if the
 * device is powered from the USB bus.
 */
#define USB_CFG_MAX_BUS_POWER           100
...
#define USB_CFG_DEVICE_CLASS        0    /* set to 0 if deferred to interface */
#define USB_CFG_DEVICE_SUBCLASS     0
/* See USB specification if you want to conform to an existing device class.
 * Class 0xff is "vendor specific".
 */
#define USB_CFG_INTERFACE_CLASS     3   /* define class here if not at device level */
//#define USB_CFG_INTERFACE_CLASS     0   /* define class here if not at device level */
#define USB_CFG_INTERFACE_SUBCLASS  0
...
/* ----------------------- Optional MCU Description ------------------------ */

/* The following configurations have working defaults in usbdrv.h. You
 * usually don't need to set them explicitly. Only if you want to run
 * the driver on a device which is not yet supported or with a compiler
 * which is not fully supported (such as IAR C) or if you use a differnt
 * interrupt than INT0, you may have to define some of these.
 */
/* #define USB_INTR_CFG            MCUCR */
/* #define USB_INTR_CFG_SET        ((1 << ISC00) | (1 << ISC01)) */
/* #define USB_INTR_CFG_CLR        0 */
/* #define USB_INTR_ENABLE         GIMSK */
#define USB_INTR_ENABLE_BIT     INT2
/* #define USB_INTR_PENDING        GIFR */
#define USB_INTR_PENDING_BIT    INTF2
#define USB_INTR_VECTOR         SIG_INTERRUPT2

#endif /* __usbconfig_h_included__ */


The usbPoll() function is called by Timer Interrupt 2, because the main loop sometimes require more than 200ms seconds to finish a cycle:

Timer configuration as C-Code:

Code: Select all

#define USB_POLL_TCNT_START 25000 // Works only for notebooks

...

  // USB Poll with Timer1 (16Bit)
  TCCR1A = 0x00;
  TCCR1B = (1 << CS10); // prescale = 0
  TCNT1 = USB_POLL_TCNT_START;
  TIMSK |= (1 << TOIE1);


The physical connection equals the wiki Z-Diod example and the used USB-Cable lenght is 1 meter.

Everything works well, in case that the used PC is a notebook.
But in case of my ASRock mini PC the device got only identyfied in case that USB_POLL_TCNT_START is define as 45000.
But the problem is that the device continiously got reset send by the kernel. I've also tryied some different kernel but without any success...

Here are a few kernel syslog messages...

Code: Select all

Apr 8 09:51:33 druebox kernel: [91646.996056] usb 5-2: new low speed USB device using uhci_hcd and address 4
Apr 8 09:51:33 druebox kernel: [91647.210199] usb 5-2: configuration #1 chosen from 1 choice
Apr 8 09:51:33 druebox kernel: [91647.265686] generic-usb 0003:16C0:05DF.0003: hiddev96,hidraw1: USB HID v1.01 Device [klaute LEDMatrix] on usb-0000:00:1d.3-2/input0
Apr 8 09:51:44 druebox kernel: [91657.616075] usb 5-2: reset low speed USB device using uhci_hcd and address 4
Apr 8 09:52:11 druebox kernel: [91684.780095] usb 5-2: USB disconnect, address 4


If some one have a idea or solution for this problem, feel free to comment.

For mor details about the AVR's firmware have a look at https://stud.hs-heilbronn.de/~klauterb/ ... matrix.htm

Thanks,
klaute

Re: Weird VUSB Linux disconnect...

Posted: Fri Apr 16, 2010 8:27 am
by PHermansson
My devices works with Ubuntu 9.10 if connected to a hub, but not if connected directly to the USB-ports on the computer. I once saw a bug-report about that, will see if I find it again.

Re: Weird VUSB Linux disconnect...

Posted: Fri Apr 16, 2010 5:01 pm
by ulao
really? I wonder if its related to my problem

viewtopic.php?f=8&t=4149

Please see if you can dig that up, maybe I need to update my v-usb firmware.