Page 1 of 1

Atmega328p + V-USB Linux Problems

Posted: Fri Feb 21, 2014 10:28 pm
by cube
Hi,
I’m using the Arduino V-USB library (http://code.rancidbacon.com/ProjectLogArduinoUSB) on an Atmega328p to use it as a HID. This is working fine on Windows and Mac, on Linux (Lubuntu) however it’s not working properly – it gets disconnected and then reconnected all the time and I have no clue why. Do you have an idea what to change to make it work on Linux, too?
Here is the edited version of usbconfig.h http://pastebin.com/HbDGe3Pt.
Here is a my layout:
Image
Image
And a prototype of the layout:
Image
Here is my basic code:

Code: Select all

#include <HIDSerial.h>
#include "TimerOne.h"

HIDSerial serial;

void setup(){
  serial.begin();
  Timer1.initialize(1000);
  Timer1.attachInterrupt(poll);
}

// interrupt timer
void poll(){
    serial.poll();
}

void loop(){
  serial.print("a");
  delay(100); // arbitrary delay to limit data to serial port   
}


It would be so great if someone had an idea…
Thanks in advance,
Cheers,
Tim

Re: Atmega328p + V-USB Linux Problems

Posted: Sat Feb 22, 2014 4:20 pm
by martinay
Hi Cube,

I don't see any problem with your schematic and usbconfig.h.
But why are you using timer to do the polling ? Did you have tried with an infinite loop which call the poll function ?

Re: Atmega328p + V-USB Linux Problems

Posted: Sat Feb 22, 2014 7:42 pm
by cube
Hi martinay,
thanks for your answer!
I have tried what you suggested (no timer) like this:

Code: Select all

void loop(){
  serial.poll();
}

This does not produce errors but does not output anything ether… When I disconnect the device cable, there is an error »hid_read() returned error« (in »HID API Test Tool«).
When I add a print() to it like this:

Code: Select all

void loop(){
  serial.poll();
  serial.print("?");
}

Now I receive 8 bytes multiple times and after a vey short time I see the same error like without the print() multiple times (for every print-call!?).

The same code runs fine for hours on Mac/Windows.

Do you know about USB driver differences between Mac/Windows and Linux which could cause this? I am using LibUSB as a driver.

Re: Atmega328p + V-USB Linux Problems

Posted: Mon Feb 24, 2014 4:50 pm
by martinay
Hi Cube,

Unfortunately, I don't have much more idea to suggest...

Or, maybe this little one : Try to use the HIDSerialMonitor client provided in this package https://github.com/rayshobby/hid-serial.
(When I experimented HID on my Linux host to write Kernel Driver, I've used that tool to do diagnostics)

You can also compare its firmware implementation with your, or even try the "Hello World" example by tweaking the usbconfig.h to match your hardware and see if the disconnect problem still there.

BTW, what "dmesg" reports on your Linux machine ? Are the "disconnect/reconnect" messages shown there also ?

Re: Atmega328p + V-USB Linux Problems

Posted: Tue Feb 25, 2014 6:38 pm
by ulao
what watt are the 3.6v's

Re: Atmega328p + V-USB Linux Problems

Posted: Sat May 16, 2015 11:10 pm
by robert
You should check with hid device like example mouse to rule out real problems with usb resets