Custom Atmega16u2 Breakout Board "Unknown Device "

First of all.. Hi Everyone , would like to thank the guys, gals, noobs and pro's and everyone else who worked on arduino for making a awesome product with endless capabilities !!!

Ok..

So I have this project that I've been working on quite some time which requires me to use a USB to Serial device, So I thought great lets use the ATMEGA16u2 device add a 3.3v supply and a 8Mhz xtal.. So everything went accordingly soldered all my smd stuffs, and finally plugged it into the usb... Amazed It worked.. Under Device Manager I saw ATMEL 16u2 DFU..

So I reckoned step 2 was to upload the Arduino firmware for the serial device. So I thought a bit... Didn't really know which one to upload. So I grabbed the first one I got from:

arduino-1.0\hardware\arduino\firmwares\arduino-usbserial\Arduino-usbserial-atmega16u2-Uno-Rev3.hex

And uploaded it with avrstudio 5 and my AVRISPmk2 with

EXTENDED: F4
HIGH: D9
LOW: EF
LOCKB: CF

So after all of this I am stuck with a annoying windows message saying "USB device not recognised" Under Device manager it says Unknown Device under USB...

And it doent matter what usbserial/...hex I burn to the micro the result stays the same. To make matters worse I build a second usbserial breakout.. And foolishly made the same mistake.

:confused:
Any help ?

Just to add: I am using arduino1.0 under windows7 64bit.

Ahhh... Little sigh of relief...

I read here : http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=110354&start=0

Brutte - Sep 14, 2011 - 07:21 PM
Post subject: RE: Atmega8U2 programming Look what I have found recently:
http://www.avrfreaks.net/index.php?modu ... em_id=1140
With m8U2 and usb82 DFU bootloaders from Atmel (It says).
So I downloaded and peeked at usb82, and it seems it also has 7 trampolines, jmp, call, SPM for BLB, sleep, call+ret pairs, but no brid-s, no SREG_T references. Lots of 0x0000 and 0xFFFF opcodes.
This bootloader uses about 3k of (effective) space.

Mind I didn't test it, as I do not have usb82.

So I went here : http://www.avrfreaks.net/index.php?module=Freaks%20Tools&func=viewItem&item_id=1140

AVR USB Bootloader Files

Updated: Sep 9, 2011
Description

Reflash of the USB bootloader for AVR controllers required? All original Atmel bootloader files available for free download.

  • AT90USB82
  • AT90USB162
  • ATMEGA8U2
  • ATMEGA32U2
  • ATMEGA16U4
  • ATMEGA32U4
  • AT90USB646/647
  • AT90USB1286/1287
    Categories

none

Version Presented by Website Price Rating
(Find Distributor) Reusch Elektronik... Free! Rank: 5

So I went here : http://www.reworld.eu/re/en/products/u2dil/index_bl.htm

And discovered all of the above mentioned files.

So Windows now see my once thought dead atmega16u2 as an AT90USB162 which is fine and as an added bonus I can connect to them using flip..

Ok... So in Atmel FLIP I tried to upload both of these (Arduino-usbserial-atmega16u2-Mega2560-Rev3 and Arduino-usbserial-atmega16u2-UNO-Rev3).

In both cases windows then see the usb2uart as Unknown devices .

Any insights ?

Dont want to, but have to ... BUMP

This is a case where Atmel and Microsoft haven't quite closed the loop.

Right-click the device in the device manager, click "install/update driver," and navigate to the .inf file for the Arduino Uno.

@ jwatte.. When I try to select a diffrent inf driver file .. Device manager says best driver is allready installed. Even though its a unknow device

:confused:

But luckly I can get these boards back to there initial states by loading the original firmware on them. But otherwise I cant use them yet.. It just breaking my brain a bit. I have succecfully reflashed an UNO board with a 8u2 usb 2 serial on and it worked but this... nope...

found any solution? i'm stucked with an arduino due based board, i've flashed the at16u2 but it's stil an unknown device for my windws7

I am doing something similar, and getting what I think is the same problem. I have an idea of what the root cause may be, but I am new at this, and I am not sure. I think the problem is the prescaler value for USB operation might need to change when changing from 16 MHZ to 8MHz. Does anyone know where this should be changed if you think this is the issue ?
see below.

I have build a PCB like the 2560 board with the ATmega8U2 chip as my serial to USB.
The target is to run the whole board off of 3.3V (stepped down from Li-ion battery)
While running the board at 5V, I can program both devices with the AVR pocket programmer.
Programmed the ATmega8U2 with :
avrdude -p at90usb82 -F -c usbtiny -U flash:w:MEGA-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

I changed the Mega2560 definition in the arduino boards.txt file for a 8 MHZ crystal, and re-programmed it successfully in the Arduino IDE.
I ran the blink example successfully.

Still running at 5V…
I then changed the crystal (ceramic resonator) on the ATmega8U2 to 8 MHZ… and now windows complains “Unknown USB device”
So I tried to re-program the device with the AVR pocket programmer: MEGA-dfu_and_usbserial_combined.hex, and that was successful. (7452 bytes of flash verified) .
So I believe that the crystal is successfully running at 8 MHz.

I tried to connect to USB, and the same issue. “USB device not recognized”
When I look at the ATmega8U2 datasheet I can see that the USB PLL prescaler lies between the USB and the crystal…
Datasheet: “The USB is provided with a dedicated clock domain. This clock is generated with an on-chip PLL
running at 48 MHz. The PLL always multiply its input frequency by 6. Thus the PLL clock register
should be programmed by software to generate a 8 MHz clock on the PLL input.”
the variable is PINDIV

Datasheet: register PLLCSR Bit 2 - “When using a 8 MHz clock source, this bit must be set to 0 before enabling PLL (1:1).”

If this guess is all correct, then can someone point me to a .hex file that supports 8MHZ for ATmega8U2 ?
Or does someone have a good tutorial on developing / creating / modifying .hex files?
Is the best way to use Atmel Studio ?

I could be wrong, but the fact that you get any response when you plug the USB in suggests to me that the protocol - and therefore the crystal frequency - is correct to a point.

I would be thinking about other aspects of the USB configuration.

Suggestion: see if Linux will recognise it.

I can try running Arduino off of a Rasberry Pi perhaps. (I have never tried before)

However, the board (atmega8u2) worked fine initially with 16 MHz crystal I changed it to 8 MHz crystal, and then it failed.
The programmer still works. So I know that internally the device is still working.
I know that there is a prescaler prior to the USB PLL which steps the frequency up.
I do not know of a way that the system would know that the crystal has changed.
The datasheet also says that this register should be programmed by software.

Similarly I realized that the UART speed between the atmega8u2 and the Mega2560 might also be messed up.
Do you know where the PLLCSR register is being configured in the Arduino system ?
Someone must have run this device at 8MHz before, and created a Bootloader.

mccartes:
However, the board (atmega8u2) worked fine initially with 16 MHz crystal I changed it to 8 MHz crystal, and then it failed.

Hey,

It’s not as simple as just changing the crystal and expect it to work… The clock has to be changed in the firmware also… I changed the clock to 8Mhz and recompiled the firmware for you… This firmware is only for the USB serial, without the DFU… Try it out and report back…

//Basel

Arduino-usbserial.hex (11.2 KB)

Wow, thank you.
Could you outline what you did to make the change and compile the hex file?
Which compiler, which source files are needed, libraries etc ?
I am hoping that I could figure out how to do this myself next time.
I have not used make directly before.

I had been looking at the F_CPU define used in atmegaboot.c however it was commented out at the top of the file.
"//#define F_CPU 16000000"
I assumed then that it was being defined somewhere else but I could not find it.

It looked like the crystal frequency might be set in the make file for the firmware, but I was not certain.
"DEFS = -DF_CPU=16000000 -DBAUD_RATE=19200"

The file loaded, and when I plug it in to the USB it came up as Arduino UNO.
Then windows could not find the driver. I'll have to investigate after work.
Thanks again for the help.

mccartes:
Could you outline what you did to make the change and compile the hex file?

Just one small change in the "makefile".. If you go down a bit you'll see a line that says the following..

F_CPU = 16000000

Just change it to:

F_CPU = 8000000

This actually defines the clock reference everywhere in the code.. So by changing it there it'll change everywhere that it's needed during compiling..

mccartes:
Which compiler, which source files are needed, libraries etc ?

I used the avr-gcc that comes with the arduino ide.. So nothing new there.. You need the LUFA libraries/files.. Not any LUFA release will work, but a specific release, LUFA-100807...

mccartes:
I have not used make directly before.

Well, you need some kind of linux environment in-order to make that particular project.. I used cygwin, which is some kind of linux shell for windows (http://www.cygwin.com/).. From there all I had to do is go into the directory for the makefile using "cd" and then type make!

//Basel

mccartes:
The file loaded, and when I plug it in to the USB it came up as Arduino UNO.
Then windows could not find the driver. I'll have to investigate after work.
Thanks again for the help.

Just point windows to the arduino uno drivers, for example:

C:\arduino-1.0.5\drivers

Unfortunately this has not worked so well. Note that I am using 1.0.4
The board comes up as an Arduino UNO for some reason.
Then it fails to find the driver even when I point it to the directory as you noted. .
When I force it to use the Arduino.inf, I get the board as %mega2560.name%

Then when I try to upload a sketch it times out : “avrdude: stk500v2_ReceiveMessage(): timeout”
I tried using a new modified board definition that I had used before: as well as the original atmega 2560 board in the IDE.
I tried some of the drivers in the old arduino drivers zip file, without luck.

Here is one thread with respect to this string: Definition of string mega2560.name is missing in arduino.inf · Issue #1314 · arduino/Arduino · GitHub
However it is hard for me to figure out what problem actually leads to this message / symptom. It seems that there are a number of different problems / solutions with this symptom.

Any suggestions ?

It should say Arduino UNO because the name is set in the makefile as Arduino UNO, so no problems there... Will you for the sake of it download Arduino 1.0.5 and try those drivers.. Because the drivers in arduino 1.0.5 are signed drivers.. Maybe that will skip some of the windows errors that come up..

//Basel

Ok, I installed 1.0.5, and the symptoms are the same.
Windows does not find the driver, and then I point it to the driver directory, and it still does not work. (uploading the blink program results in time outs)
When I force windows to use the Arduino.inf driver, and select the Mega2560, I have the same timeout issue.
I then uninstalled the driver, and reinstalled forcing it to be recognized as Arduino UNO, and I have the same issue.
I have some ideas for debugging / going back to 16 MHz crystal and double checking that everything is fine. etc. I'll let you know how it goes.

Ok, I finally recovered to a known state, and I have the board back up and running. The Arduino Mega board is running at 8MHz successfully, and now I need to get the atmega8u2 running at 8 MHz. Do you know of a known good bootloader + fuse settings for the 8u2 for 8 MHz ?

Here are the steps I took to get back to a known good state. (Is there a user manual for this post editor ?)

  • Known good ATMEGA 2560 board running 16MHz:
  • Success programming bootloader with AVRISPMKII: in Arduino IDE
  • Success programming with command line AVR dude: program_mega2560
  • avrdude -c avrispmkII -p m2560 -P usb -U flash:w:stk500boot_v2_mega2560.hex
  • Success programming mega16u2 USB converter
  • Read out hex, and wrote it back
  • Read: avrdude -c avrispmkII -p m16u2 -P usb -U flash:r:original_atmega16u2.hex:I
  • Write the hex file back: avrdude -c avrispmkII -p m16u2 -P usb -U flash:w:original_atmega16u2.hex
  • FM board: changed to 16 MHz crystals, 5V operation Jumper USB to VCC programming pin
  • Successfully programmed Mega 2560 flash from command line with fuse bits for 16 MHz (default arduino)
  • avrdude -c avrispmkII -p m2560 -P usb -U flash:w:stk500boot_v2_mega2560.hex lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFD:m -U lock:w:0x0F:m
  • Programmer Ribbon cable away from the device
  • Note that to power the board both the USB as well as the programmer are plugged in at the same time.
  • Successfully programmed the atmega8u2 USB converter with 16 MHz crystal settings
  • avrdude -c avrispmkII -p atmega8u2 -P usb -U flash:w:Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex
  • Successfully built and ran blink on the board !! Yay
  • Change crystal (ceramic resonator)to 8MHz for the 2560 (keep 5V)
  • Successfully programmed 2560 with hex and fuse settings from Sparkfun mega pro
  • avrdude -c avrispmkII -p m2560 -P usb -U flash:w:MegaPro3.3V-8MHz-57600.hex lfuse:w:0xE2:m -U hfuse:w:0xD4:m -U efuse:w:0xFD:m -U lock:w:0x0F:m
  • Updated arduino boards.txt file with board definition from sparkfun mega pro
    Successfully ran blink on the board !! yay

stk500boot_v2_mega2560.hex (614 KB)

Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex (11.1 KB)

MegaPro3.3V-8MHz-57600.hex (4.86 KB)

Baselsw: Ok, I then changed the crystal on the atmega 8u2 to 8 MHz and successfully programmed the device with the usb to serial driver you supplied on October 14th.

  • It does not work.
    It correctly comes up as a com port (COM 7) in this case.. but when the device is programmed it times out:
    avrdude: stk500v2_ReceiveMessage(): timeout

I'll try to re-compile the .hex file on a raspberry pi.
Thanks