Go Down

Topic: A000073 - Arduino UNO SMD Rev3 (atmega16u2 and atmega328p-mu) bootloading (Read 5621 times) previous topic - next topic


Dear all,

I have built a board based on A000073 schematic with an atmega16u2 and a atmega328p-mu. The strange thing is that:
- I am able of programming the atmega328p-mu using ISP interface. I program it with another of my arduino boards using it as ISP programmer.
- I am also able of downloading an .hex file to the atmega16u2 using Flip and the normal known process.

The problem is that it is imposible that both micros talk together using Rxd and Txd.

For debugging it, I am connecting an 'UART to USB' board converter from FTDI, and I see how atmega328p with the AnalogReadSerial converter app loaded sends data to the pc at 9600baudios.

I also have checked the loopback test with the atmega16u2 with "Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex" loaded and it runs at 9600 bauds (and all the others baudrates).

But if I connect both them together, I only get garbage in the port. This garbage is related with the data sent (size, rate) but is not the data sent.

Is there any serialport setting I am missing?

What I am doing wrong?

Please, give me some idea or help.

Best regards,


Since no one have answered, I am going to give some more data of the work made today:

1. I have check avrdude to check fuses and seems to be ok for my atmega328p.

2. I have tried again to download AnalogReadSerial.ino changing code in order that always writes 'a' in the port. As yesterday, I can see it with the FTDI UM230XB board, and indeed I have achieved to see it with the Arduino IDE connecting my atmega328p-mu board to an Arduino Board (taking out first its original atmega328).

3. Next step, I reconnect Txd, Rxd and Reset from my atmega328p-mu board to the Arduino board. My idea is try to burn the atmega328p using the serial interface as a normal Arduino board. This crashes, I get stk500_getsync() errors.

What I am doing wrong?

Kind regards,



I've little experience with the Atmega16u2 so probably can't help with that, but it sound like you have loaded it with the firmware it needs. On the Atmega328p, you will also need to load the bootloader "optiboot" (just search in the files where your Arduino ide installed or check https://github.com/Optiboot/optiboot).

Once the 328p has a bootloader it can then be loaded with the Arduino IDE, which runs something like "avrdude -p m328p -P COM2 -c arduino -U flash:w:BlinkLED.hex" to load BlinkLED firmware.

In step 3 (of post #2) it sounds like you are using the 16u2 from an existing Uno board to drive the RX/TX and RESET of your board, and I think that could work but would want to remove the 328p from the Uno board since it will also get programmed (and more likely disrupt the communications).


Sep 24, 2015, 12:38 pm Last Edit: Sep 26, 2015, 03:14 am by Nick Gammon Reason: QUOTE tags changed to CODE tags
Thanks a lot Ron,

First of all, I think I am online with your suggestions (I made things as you said).

I have achieved the next thing:
1. Using my Arduino IDE 1.6.5, I prepare one A000073 loading into it the 'ArduinoISP.ino' file.
2. I use my A000073 as ISP programmer prepared as point 1, for burning the bootloader (IDE 1.6.5, Tools->Arduino as ISP, Tools-> Programmer "Arduino as ISP") and then I make Tools --> Burn Bootloader. --> All seems to go ok, indeed I see the triple blinking in my board.
3. I take my Arduino A000066 (without atmega328p) and connect to my board (using Tx, Rx, Reset, Gnd and 5V from the A000066).
4. I run again the Arduino IDE and upload any app using Tools-->Verify/Compile, and then Tools-->Upload.

The misterious thing: I have never achieved this, but I have achieved it once!!!, and then no way, anymore. Fortunately I copied the IDE messages of the success uploading. And I want to ask if anyone sees anything strange that could help me:

Code: [Select]
Sketch uses 1.958 bytes (6%) of program storage space. Maximum is 32.256 bytes.
Global variables use 186 bytes (9%) of dynamic memory, leaving 1.862 bytes for local variables. Maximum is 2.048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM17 -b115200 -D -Uflash:w:C:\Users\CDP81007\AppData\Local\Temp\build3646358210213853657.tmp/AnalogReadSerial.cpp.hex:i

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM17
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino


Dear all,

I have taken oscilloscope, and this what I have seen: atmega16u2 is transmitting to the UART 8 times slower than it shoud do. I have checked crystal, which seems to go at expected 16MHz.

I have my doubts now about the .hex files that comes with the Arduino IDE 1.6.5, I have two in the installation folder, and none of both them seems to work with my board:

· C:\Program Files (x86)\Arduino\hardware\arduino\avr\firmwares\atmegaxxu2\Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex

· C:\Program Files (x86)\Arduino\hardware\arduino\avr\firmwares\atmegaxxu2\arduino-usbserial\Arduino-usbserial-atmega16u2-Uno-Rev3.hex

My real question, is can anybody tell me which and where must I take the correct .hex file for an Arduino A000073 board with atmega16u2 and atmega328p assembled.

Really, I am also surprised of not found schematics. They do not exists, but my board is official (I bought it on Farnell). I attach a picture.

Kind regards,



I have made another test:
1.- I have downloaded a simple app to my atmega328p which only sends 'a' character to the port at 7200 bauds.

2.- I have connected it to my atmega16u2 with Arduino-usbserial-atmega16u2-Uno-Rev3.hex downloaded from github (https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial-atmega16u2-Uno-Rev3.hex[/url].

3.- Then I open my 1.6.5 IDE, and open serial port console at 57600 bauds (just 7200 x 8 = 57600), and I have it: now I am able of reading data sent by atmega328p: aaaaaaaaaaaa...

My questions are:
- Is there any suitable .hex file for atmega16u2 + atmega328? How can I get it?
- If the .hex file in github is ok, why I get this errors (I am using Flip proccess as described on https://www.virtuabotix.com/how-to-cure-sudden-uno-death-syndrome/, but of course choosing atmega16u2 and using the github .hex file I told in point 2).



I haven't done any 16U2 programming, but it seems you are on the right path.

What are the A000066 and A000073 boards that you refer to?

The 7200/57600 issue would indicate the fuses in one or both chips are not set correctly. The system clock divide by 8 would seem to be at its default setting (divide by 8) vs running at the full system clock speed.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


 I looked at the Leonardo in the boards.txt file (where Arduino installed ..\hardware\arduino\avr). This should give some clues on how to set the fuse.

Code: [Select]


Ignore that it is for a Leonardo bootloader, I'm just fishing for ideas about the fuse settings on 16U2.

So then I looked over the options and think you want to minimize the boot flash section which changes the high fuse to DF, anyway have a look at this link:


I have taken oscilloscope, and this what I have seen: atmega16u2 is transmitting to the UART 8 times slower than it shoud do. I have checked crystal, which seems to go at expected 16MHz.
That usually means you have the "divide clock by 8" fuse set.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics


The problem is that it is imposible that both micros talk together using Rxd and Txd.
That would be a side-effect of the wrong baud rate, due to the fuse dividing the clock by 8.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics


Thanks all for your advices.

Finally I have bought an AVRisp MK2 from Olimex. I am trying to access ICSP interface on my atmega16u2 board (since it is qfp, I have some problems). Really, I think you are right about this issue, but still had no time to check it.

I have gone right ahead to the amtega328p-mu, trying to use it with a sparkfun FTDI board (https://www.sparkfun.com/products/9716), for avoiding to use atmega16u2. But also I have no success. I have the next problem:

1. I flash ATmegaBOOT_168_atmega328.hex using Atmel AVR Studio 6.2.
2. I set fuses as everybody says (attached pictures). It is strange because I have checked arduino pro and arduino uno SMD, and they do not match what all the people says. :o
3. I go to the IDE, choose 'Arduino Pro or Pro Mini', and atmega328 (5V,16MHz).
4. I choose AnalogReadSerial.ino, and Sketch->Verify/Compile, Sketch->Upload.
5. The app goes ok, I see data on serial port.

Now I try to RELOAD again the app following step 4, but it is not posible. It seems like bootloader has been corrupted or anything like that.

So, I suppose there are some mistake between atmega328p-mu bootloader, fuses and Arduino IDE, but after thousands of tests, I have not achieved anything.

Any idea?

Thanks a lot,


The boards.txt file has some setting you need to be aware of, it is where Arduino was installed.

... \Arduino\hardware\arduino\avr\boards.txt

If you use the ATmegaBOOT_168_atmega328.hex file the settings look like

also, the bootloader speed is 57600

Looking at the extended fuse, only the last three bits are used so 0x5 is the same as 0xFD.

Looking at the high fuse, the boot size is 1k to hold the ATmegaBOOT_168_atmega328.hex bootloader. For an Uno if you look at the boards.txt file you will see the bootloader is different it is optiboot_atmega328.hex and the high fuse is 0xDE because optiboot fits in 256 bytes. So if you set the small bootflash section then the bootloader likely nuked itself, but I would think it would die in the process and not even finish uploading the firmware.




Hi all,

Finally solved. I just wanted to summarizes a little and give thanks to all of you, you answered very quick. I will try to help too in the future, since I have learnt a lot in this 2 weeks of hard working.

So, if you plan to do a board with an atmega16u2 + atmega328p-mu (QFP32), yes you can, don't be afraid.

Simply, do not forget to do the next things:
1. Include the ICSP ports for both micros in your board. You can work with an Olimex AVRisp MK2, sure you need it at least for atmega16u2. You should install Atmel AVR Studio (6.2 version is ok) for working with ICSP programmer. Sure, many others ICSP programmers works.

2. Set your fresh unprogramed atmega16u2 to: (you must follo steps in this order):
2.1 First: program it with Arduino-usbserial-atmega16u2-Uno-Rev3.hex.
2.2 Set the fuses at: LFuse = 0xEF, HFuse = 0xD9, EFuse = 0xF4, Lock byte = 0xCF.

3. Set your fresh unprogrammed atmega328p-mu (5V, 16MHz) (you must follo steps in this order):
3.1 First: program it with ATmegaBOOT_168_atmega328.hex
3.2 Fuses: using Atmel AVR Studio you should see extended = 0xFD, High =0xDE, Low=0xFF. Please, note that AVR Studio set to 1 not used bits from fuses, so, extended fuse 0xFD really means 0x05 (because bits 3-7 are not used) . If you do not believe, try it, check also atmega328p datasheet.
3.3 Fuse Lockbyte = 0xCF (means 0x0F, also some bits are not in use, and setted by AVRStudio to 1).

Then, it should work like a normal Arduino Uno board.

Thanks again Ron, Cross and Nick.

Nice weekend :D


I have some issues with your "it must be in this order" comments, but those are just nits.

program it with ATmegaBOOT_168_atmega328.hex
Then, it should work like a normal Arduino Uno board.
Programming a chip with ATmegaBOOT_168_atmega328.hex should give you a "Duemilanova with mega328" equivalent.  To get an Uno equivalent, you need to program it with optiboot_atmega328.hex from the bootloaders/optiboot directory.  (the two bootloaders run at different speeds, so sketchs won't load if the bootloader and board type don't match.)


In step 3.2 you have set the high fuse to 0xDE which sets the Boot Flash section at 256 bytes and that means ooptiboot_atmega328.hex will fit, but the ATmegaBOOT_168_atmega328.hex bootloader needs 1k bytes Boot Flash section (didn't it overwrite itself before when 256 Boot Flash section was set?).

Go Up