ATmega168 BootloadHID - Device not recognized

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Alan Chatham
Rank 1
Rank 1
Posts: 28
Joined: Wed Sep 30, 2009 3:36 am
Location: Osaka, Japan
Contact:

ATmega168 BootloadHID - Device not recognized

Post by Alan Chatham » Tue Dec 15, 2009 2:16 am

After fighting for a day trying to get BootloadHID to compile in AVR Studio 4, here's what I've got -

As supplied (after altering some of the include paths to point in the right places), AVR Studio compiles with the following errors - seems like a linker problem?

Code: Select all

../usbdrv/usbdrv.h:213: warning: 'usbFunctionDescriptor' used but never defined
../usbdrv/usbdrv.h:220: warning: 'usbSetInterrupt' declared 'static' but never defined
avr-gcc  -mmcu=atmega168 -Wall -gdwarf-2 -std=gnu99     -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT oddebug.o -MF dep/oddebug.o.d  -c  ../usbdrv/oddebug.c
avr-gcc  -mmcu=atmega168 -Wall -gdwarf-2 -std=gnu99     -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT usbdrv.o -MF dep/usbdrv.o.d  -c  ../usbdrv/usbdrv.c
../usbdrv/usbdrv.h:186: warning: 'usbFunctionSetup' used but never defined
../usbdrv/usbdrv.h:213: warning: 'usbFunctionDescriptor' used but never defined
../usbdrv/usbdrv.h:249: warning: 'usbFunctionWrite' used but never defined
../usbdrv/usbdrv.c:608: warning: 'usbInit' defined but not used
../usbdrv/usbdrv.c:566: warning: 'usbPoll' defined but not used
../usbdrv/usbdrv.h:220: warning: 'usbSetInterrupt' declared 'static' but never defined
avr-gcc  -mmcu=atmega168 -mmcu=atmega168 -Wall -gdwarf-2 -std=gnu99     -DF_CPU=16000000UL ...........
avr-gcc -mmcu=atmega168 -Wl,-Map=Mouse.map main.o oddebug.o usbdrv.o usbdrvasm.o     -o Mouse.elf
usbdrv.o:(.data+0x0): multiple definition of `usbTxLen'
main.o:(.data+0x0): first defined here
usbdrv.o:(.progmem.data+0x0): multiple definition of `usbDescriptorString0'
main.o:(.progmem.data+0x0): first defined here
usbdrv.o:(.progmem.data+0x4): multiple definition of `usbDescriptorStringVendor'
main.o:(.progmem.data+0x4): first defined here
usbdrv.o:(.progmem.data+0x16): multiple definition of `usbDescriptorStringDevice'
main.o:(.progmem.data+0x16): first defined here
usbdrv.o:(.progmem.data+0x26): multiple definition of `usbDescriptorDevice'
main.o:(.progmem.data+0x26): first defined here
usbdrv.o:(.progmem.data+0x38): multiple definition of `usbDescriptorConfiguration'
main.o:(.progmem.data+0x38): first defined here
make: *** [Mouse.elf] Error 1
Build failed with 1 errors and 8 warnings...


Meanwhile, if I compile it with MinGW/AVRDUDE and the supplied makefile, I get the following complier warnings:

Code: Select all

../usbdrv/usbdrv.h:213: warning: 'usbFunctionDescriptor' used but never defined
../usbdrv/usbdrv.h:220: warning: 'usbSetInterrupt' declared 'static' but never defined


and the resulting .hex file, once flashed into the chip (via AVR Studio - can you not do that?), doesn't connect to my PC (running windows XP). For some reason, in the initForUSBConnectivity() function, the function that simulates a disconnect to force re-enumeration, it causes the device to reset every so often while running through the main loop of the bootloader code,so that little "device not recognized" bubble pops up repeatedly while plugged in unlike where it usually only goes once. Under device manager, the "Unknown Device" claims that it can't find the driver.
Other executables work fine; I've done a couple projects with V-USB before with the ATMega168, so I don't think it's my fuses (famous last words...). I've tried setting it with both the boot reset vector enabled and disabled as well, though, with no change.

So I was wondering if anyone else has had problems/success compiling the BootLoadHID project for the 168, or if anyone has any tips that could help me out?

Thanks!

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

Re: ATmega168 BootloadHID - Device not recognized

Post by ulao » Tue Dec 15, 2009 3:26 am

Hey I use the boatloader with my 168. And I have also seen these errors. I can not offer you an answer for what they mean but I can tell you what I saw cause and fixed them. I get those errors when my usbconfig does not match the latest .0 files ( some inconsistency ). The fix for me was to either go back to an older version of usb-v and use that usbconfig ( and make my changes ) or get the latest and do that same. In both cases I had to use the supplied config file and then add in may changes. I have had this happen on a few occasions now, same errors. Hope it works for you..

Alan Chatham
Rank 1
Rank 1
Posts: 28
Joined: Wed Sep 30, 2009 3:36 am
Location: Osaka, Japan
Contact:

Re: ATmega168 BootloadHID - Device not recognized

Post by Alan Chatham » Tue Dec 15, 2009 7:42 am

Thanks, ulao- I got it to compile with AVR Studio as well now, with no errors or warnings. Also, for anyone who is having the same linker problems with AVR Studio, it arises from including usbdrv.c instead of linking against it. HIDBootloader includes it to save some bytes; the trick to get it to compile is to remove the usbdrv.c file from your project files in AVR Studio (don't delete it, though). Otherwise, the compiler will compile usbdrv.c into a separate object file, then all the functions in usbdrv.c get included into your main.c file, get compiled into main.o, and then the linker freaks out since you have re-declared your functions in different places.

I'm still getting the same non-connectivity, though, with the repeating "USB Device not recognized" error... was the problem that you fixed by changing the driver version just the compilation problems, or the usb connectivity thing?

Thanks again!

Alan Chatham
Rank 1
Rank 1
Posts: 28
Joined: Wed Sep 30, 2009 3:36 am
Location: Osaka, Japan
Contact:

Re: ATmega168 BootloadHID - Page size of negative 128

Post by Alan Chatham » Wed Dec 16, 2009 3:49 am

So I got it to compile, and be recognized by my computer. Some of it had to do with writing it to the correct part of memory using AVR Studio. However, for some reason, I'm still unable to use the HIDBootFlash tool. It recognizes the device, but lists the page size as -128... Clearly not correct. If I try and flash the chip from it, it outputs the following sort of results:

Code: Select all

Flashing 1920 (0x780) bytes starting at 0 (0x0)
0x00000 ... 0x00080
Error flashing device!!!
...
0x00680 ... 0x00700
Error flashing device!!!
Download failed!!!!


Any ideas? Has anyone had the same issues and figured out how to fix them?

Thanks

schwa226
Rank 1
Rank 1
Posts: 20
Joined: Thu Feb 11, 2010 9:20 am

Re: ATmega168 BootloadHID - Device not recognized

Post by schwa226 » Fri Feb 04, 2011 11:21 am

So I got it to compile, and be recognized by my computer.


Hi!
I also got it compiled in AVR Studio but NOT recognized by my computer!

I changed the text address to 0x3800 for the Atmega168. Nothing else.
What did you change that the device get recognized?

kke

Re: ATmega168 BootloadHID - Device not recognized

Post by kke » Tue Jan 31, 2012 10:40 pm

Hi all,

I have BootloadHID up and running on a Mega32 microcontroller, however the software reports a negative pagesize and negative memory size when the device is found. Does anyone have any ideas on how this might be caused?

Can someone please confirm that BootloadHID fits the Mega8 Bootloader area?

BTW. I've noticed that de device does not get recognised on one USB port while it is one all others, the port that doesn't recognise the device however does work correct with other HW.

Thanks for any input,

KK.

Post Reply