Olimex AVR-USB-162 - USB examples not running

Started by red-lichtie, July 22, 2015, 10:48:05 AM

Previous topic - Next topic

red-lichtie

When I try to compile any of the "USB" examples I have found for Olimex AVR-USB-162, I'm only able to get USB errors.


I'm working on a Linux machine with:


       
  • avr-gcc 4.9.2
  • avr-binutils 2.25
  • avr-libc 1.8.1
  • avrdude 6.1
If I use the pre-compiled hex the mouse demo here: https://www.olimex.com/Products/AVR/Proto/AVR-USB-162/ it registers fine as a new USB device when connected.


Here is what the kernel log shows:

Jul 22 07:47:59 turbine kernel: usb 1-2: new full-speed USB device number 41 using xhci_hcd
Jul 22 07:48:00 turbine kernel: input: ATMEL AVR USB MOUSE DEMO as /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:03EB:202A.000A/input/input26
Jul 22 07:48:00 turbine kernel: hid-generic 0003:03EB:202A.000A: input,hidraw3: USB HID v10.01 Mouse [ATMEL AVR USB MOUSE DEMO] on usb-0000:00:14.0-2/input0


But if I try the PJRC example (http://www.pjrc.com/teensy/usb_mouse.html) or the LUFA example (LUFA-140928/Demos/Device/LowLevel/Mouse), I only get USB connection errors.


Compiling the LUFA example goes like this:


~/avr/LUFA-140928/Demos/Device/LowLevel/Mouse $  make MCU=at90usb162 BOARD=OLIMEX162 F_CPU=16000000 all
[INFO]    : Begin compilation of project "Mouse"...

avr-gcc (GCC) 4.9.2 20141224 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[GCC]     : Compiling C file "Mouse.c"
avr-gcc -c -pipe -gdwarf-2 -g2 -mmcu=at90usb162 -fshort-enums -fno-inline-small-functions -fpack-struct -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections -I. -I../../../../LUFA/.. -DARCH=ARCH_AVR8 -DBOARD=BOARD_OLIMEX162 -DF_USB=16000000UL -DF_CPU=16000000UL -mrelax -fno-jump-tables -x c -Os -std=gnu99 -Wstrict-prototypes -DUSE_LUFA_CONFIG_HEADER -IConfig/  -MMD -MP -MF Mouse.d Mouse.c -o Mouse.o

......

[LNK]     : Linking object files into "Mouse.elf"
avr-gcc Mouse.o Descriptors.o ../../../../LUFA/Drivers/USB/Class/Common/HIDParser.o ../../../../LUFA/Drivers/USB/Core/AVR8/Device_AVR8.o ../../../../LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.o ../../../../LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.o ../../../../LUFA/Drivers/USB/Core/AVR8/Host_AVR8.o ../../../../LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.o ../../../../LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.o ../../../../LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.o ../../../../LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.o ../../../../LUFA/Drivers/USB/Core/ConfigDescriptors.o ../../../../LUFA/Drivers/USB/Core/DeviceStandardReq.o ../../../../LUFA/Drivers/USB/Core/Events.o ../../../../LUFA/Drivers/USB/Core/HostStandardReq.o ../../../../LUFA/Drivers/USB/Core/USBTask.o -o Mouse.elf -lm -Wl,-Map=Mouse.map,--cref -Wl,--gc-sections -Wl,--relax -mmcu=at90usb162
[OBJCPY]  : Extracting HEX file data from "Mouse.elf"
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature Mouse.elf Mouse.hex
[OBJCPY]  : Extracting EEP file data from "Mouse.elf"
avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings Mouse.elf Mouse.eep || exit 0
[OBJCPY]  : Extracting BIN file data from "Mouse.elf"
avr-objcopy -O binary -R .eeprom -R .fuse -R .lock -R .signature Mouse.elf Mouse.bin
[OBJDMP]  : Extracting LSS file data from "Mouse.elf"
avr-objdump -h -d -S -z Mouse.elf > Mouse.lss
[NM]      : Extracting SYM file data from "Mouse.elf"
avr-nm -n Mouse.elf > Mouse.sym
[SIZE]    : Determining size of "Mouse.elf"

avr-size --mcu=at90usb162 --format=avr Mouse.elf
AVR Memory Usage
----------------
Device: at90usb162

Program:    3128 bytes (19.1% Full)
(.text + .data + .bootloader)

Data:         22 bytes (4.3% Full)
(.data + .bss + .noinit)


[INFO]    : Finished building project "Mouse".



So everything appears to compile correctly, there are no warnings at least (after fixing a LUFA error about a non existent Joystick?).


Then I program the board like this:


$  avrdude -c usbasp -p usb162 -e -U flash:w:Mouse.hex:i -B 4

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9482
avrdude: erasing chip
avrdude: set SCK frequency to 187500 Hz
avrdude: reading input file "Mouse.hex"
avrdude: writing flash (3128 bytes):

Writing | ################################################## | 100% 1.80s

avrdude: 3128 bytes of flash written
avrdude: verifying flash memory against Mouse.hex:
avrdude: load data flash data from input file Mouse.hex:
avrdude: input file Mouse.hex contains 3128 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.94s

avrdude: verifying ...
avrdude: 3128 bytes of flash verified

avrdude: safemode: Fuses OK (E:F4, H:D9, L:5E)

avrdude done.  Thank you.



But the kernel log shows this when I connect the board:


Jul 22 08:07:39 turbine kernel: usb 1-2: new full-speed USB device number 42 using xhci_hcd
Jul 22 08:07:39 turbine kernel: usb 1-2: device descriptor read/64, error -71
Jul 22 08:07:39 turbine kernel: usb 1-2: device descriptor read/64, error -71
Jul 22 08:07:40 turbine kernel: usb 1-2: new full-speed USB device number 43 using xhci_hcd
Jul 22 08:07:40 turbine kernel: usb 1-2: device descriptor read/64, error -71
Jul 22 08:07:40 turbine kernel: usb 1-2: device descriptor read/64, error -71
Jul 22 08:07:40 turbine kernel: usb 1-2: new full-speed USB device number 44 using xhci_hcd
Jul 22 08:07:40 turbine kernel: usb 1-2: Device not responding to setup address.
Jul 22 08:07:40 turbine kernel: usb 1-2: Device not responding to setup address.
Jul 22 08:07:41 turbine kernel: usb 1-2: device not accepting address 44, error -71
Jul 22 08:07:41 turbine kernel: usb 1-2: new full-speed USB device number 45 using xhci_hcd
Jul 22 08:07:41 turbine kernel: usb 1-2: Device not responding to setup address.
Jul 22 08:07:41 turbine kernel: usb 1-2: Device not responding to setup address.
Jul 22 08:07:41 turbine kernel: usb 1-2: device not accepting address 45, error -71
Jul 22 08:07:41 turbine kernel: usb usb1-port2: unable to enumerate USB device


I am at a loss as to why the examples aren't running correctly. I could really do with a pointer to get me going.


Thanks.