Atmega328p + V-USB Linux Problems

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
cube
Posts: 2
Joined: Fri Feb 21, 2014 9:43 pm

Atmega328p + V-USB Linux Problems

Post by cube » Fri Feb 21, 2014 10:28 pm

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

martinay
Posts: 10
Joined: Mon Feb 03, 2014 5:20 pm

Re: Atmega328p + V-USB Linux Problems

Post by martinay » Sat Feb 22, 2014 4:20 pm

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 ?

cube
Posts: 2
Joined: Fri Feb 21, 2014 9:43 pm

Re: Atmega328p + V-USB Linux Problems

Post by cube » Sat Feb 22, 2014 7:42 pm

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.

martinay
Posts: 10
Joined: Mon Feb 03, 2014 5:20 pm

Re: Atmega328p + V-USB Linux Problems

Post by martinay » Mon Feb 24, 2014 4:50 pm

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 ?

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: Atmega328p + V-USB Linux Problems

Post by ulao » Tue Feb 25, 2014 6:38 pm

what watt are the 3.6v's

robert

Re: Atmega328p + V-USB Linux Problems

Post by robert » Sat May 16, 2015 11:10 pm

You should check with hid device like example mouse to rule out real problems with usb resets

Post Reply