Bootloading Atmega32u4

Hello, forum,

I am prototyping with the atmega32u4 and have made my PCB with it, I designed it, got the PCB made and put it together. However, when I try to flash it with the Arduino bootloader using the Arduino Uno I get an error message. When flashing it, I flash it as an Arduino Leonardo as my board is very similar and works in the same way. The error message I get looks like this (with the verbose on):

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

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

Using Port : COM3
Using Programmer : stk500v1
Overriding Baud Rate : 19200
AVR Part : ATmega32U4
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
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 9000 9000 0x00 0x00
flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 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 : STK500
Description : Atmel STK500 Version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

Error while burning bootloader.
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
** Double check connections and try again, or use -F to override**
** this check.**

avrdude done. Thank you.

I hope someone could help with this issue. Thanks
I Have put some pictures of my board if they come to any help.

There are a couple of things that can cause that problem. One of them is power- are you definitely getting +5V to the target microcontroller like you should? Another possible cause is lack of a clock source- I don't think I can see one on your target board.
To be sure we will need to see your schematic.

Yes there is definitely a +5v source on the board as I have tested it, by the clock source do you mean is the board connected to SCK and if so yes it is. I have attached the schematic.

Launch Schematic.pdf (18.8 KB)

15mxcixj:
... by the clock source do you mean is the board connected to SCK and if so yes it is.

No, by clock source I mean a resonator or crystal for the microcontroller itself. After a closer look I can in fact see the crystal, but it is far away from the microcontroller. It needs to be as close to the microcontroller as physically possible. The same goes for the two loading capacitors. I only see one of them next to the crystal, is the other one hidden by the buzzer?

15mxcixj:
I have attached the schematic.

There are a couple of issues that I can see straight off the bat:

  1. No decoupling capacitors. Each supply pin (VCC, AVCC etc) should have a 100nF capacitor. They should be as physically close to the pin as possible.
  2. The crystal in your schematic is a 25MHz one. You need to use a 16MHz one if you are trying to use the Leonardo bootloader.
  3. The loading caps for the crystal should be 20pF, not 1uF.
  4. What is the forward voltage of your LEDs? 100 ohms is probably too low.
  5. The buzzer draws more than 20mA at 5V. You can't run it straight from the microcontroller pin, you'll need to use a relay or transistor to drive it.
  6. UGND should be connected to GND.
  7. VCC1 and AVCC1 aren't connected. They need to be.
  8. It looks like you have the MOSI and MISO lines around the wrong way, but it is a bit hard to tell because you've used the same colour wire for both of them and have them crossing each other.

Have you also checked the voltage on the reset pin of the ATMega32U4? There is no reset button in the schematic, so I can't check, but it is fairly common to wire the button incorrectly so that it is always shorted to ground.

  1. No decoupling capacitors. Each supply pin (VCC, AVCC etc) should have a 100nF capacitor. They should be as physically close to the pin as possible.

When designing the board I was following the atnega32u4 schematics and using their recommended values, I have placed a 10uF decoupling capacitor on the VCC line.

  1. The crystal in your schematic is a 25MHz one. You need to use a 16MHz one if you are trying to use the Leonardo bootloader.

The crystal is a 16MHz, the one on the schematic is only the footprint I needed as it suited the size of my crystal.

The loading caps for the crystal should be 20pF, not 1uF.

I will order some of those and put them in.

  1. UGND should be connected to GND

When following the Atmega schematic the UGND it didn't show it had to be connected, is this necessary for the correct working of the board?

  1. VCC1 and AVCC1 aren't connected. They need to be

Is this necessary for the correct working of the board?

It looks like you have the MOSI and MISO lines around the wrong way, but it is a bit hard to tell because you've used the same colour wire for both of them and have them crossing each other.

I'm pretty sure they are the correct way round.

There is no reset button in the schematic, so I can't check, but it is fairly common to wire the button incorrectly so that it is always shorted to ground.

There is a reset button wired in, if you press it, it will short the pin to ground. When not being pressed it connected to VCC with a 10k resistor.

15mxcixj:
When designing the board I was following the atnega32u4 schematics and using their recommended values, I have placed a 10uF decoupling capacitor on the VCC line.

The decoupling caps on the Leonard are C1 and C2. They aren't placed close to the microcontroller in the schematic so they are easy to miss, but they are there and they are necessary for the microcontroller to function correctly. There is a fairly good explanation here as to why you need them. It isn't specific to the ATMega 32U4- pretty much any microcontroller, and most digital ICs, will need decoupling capacitors.

15mxcixj:
The crystal is a 16MHz, the one on the schematic is only the footprint I needed as it suited the size of my crystal.I will order some of those and put them in.

If the future, if you want accurate help you'll need to make sure that the information you give people is correct- I don't have your board in front of me so I don't know that you have actually put a 16MHz crystal on instead of a 25MHz one.

15mxcixj:
When following the Atmega schematic the UGND it didn't show it had to be connected, is this necessary for the correct working of the board?

The Leonardo schematic clearly shows that UGND is connected to GND.

15mxcixj:
Is this necessary for the correct working of the board?

All the supply pins must be connected.

15mxcixj:
I'm pretty sure they are the correct way round.

I'll defer to what you say since the picture isn't clear. For the sake of argument, here is how it looks to me:


which does have the MISO and MOSI wires switched around.

15mxcixj:
There is a reset button wired in, if you press it, it will short the pin to ground. When not being pressed it connected to VCC with a 10k resistor.

So you have tested with a DMM and verified that the reset pin on the microcontroller itself is sitting at 5V when the button isn't pressed?

While looking at the Leonardo schematics I now realise some of the issues I had made, not sure how I missed them but I did. I put all of the VCC lines together (Missing AVCC1 and VCC1) and the whole line is connected to a 10uf decoupling capacitor. I should have connected them like it is in the Leonardo Schematic.

If the future, if you want accurate help you'll need to make sure that the information you give people is correct- I don't have your board in front of me so I don't know that you have actually put a 16MHz crystal on instead of a 25MHz one

I'm sorry about that, ill make sure to specify those things next time.

The Leonardo schematic clearly shows that UGND is connected to GND.

That's an issue I will resolve if I have to redesign and order a new PCB.

So you have tested with a DMM and verified that the reset pin on the microcontroller itself is sitting at 5V when the button isn't pressed?

The RESET pin sits at 0.035v, the 10k resistor gets 5v and after the resistor, the voltage reading is 0.035 and pressing the button does not change a thing.

15mxcixj:
While looking at the Leonardo schematics I now realise some of the issues I had made, not sure how I missed them but I did. I put all of the VCC lines together (Missing AVCC1 and VCC1) and the whole line is connected to a 10uf decoupling capacitor. I should have connected them like it is in the Leonardo Schematic.

That's a good start. Trust me, I know how easy it is to get something wrong or miss something out when you first start a PCB. Don't forget the 100nF decoupling capacitors for the supply pins too.

15mxcixj:
The RESET pin sits at 0.035v, the 10k resistor gets 5v and after the resistor, the voltage reading is 0.035 and pressing the button does not change a thing.

That's going to be an issue. It appears that you've connected the reset button like this:


Often these buttons should be connected like this instead:

What's the exact model of the button you've used?

The minute I sent the post I had realised that the button was wired in incorrectly, I cut 2 of the pins of and now the RESET pin is reading 5v, when the button is pressed it reads 0v. So that issue has been fixed, a few more to go 8). I will redesign and get back to you and confirm everything is correct. However, for now, do you see anything I could do try to fix it and make It correct, such as changing capacitor values. Or does to need a whole redesign for it to work correctly.
I've changed the resistor value for the main power on LED to 10k and tried lowering the capacitor values to 100nF, as close as I could get to 22pF with the current components I have, It showed no difference.

I have redesigned the schematic, could you please confirm if everything is correct. I made all component values the same as on the Arduino Leonardo.

Launch Schematic 2.pdf (19.3 KB)

15mxcixj:
The minute I sent the post I had realised that the button was wired in incorrectly, I cut 2 of the pins of and now the RESET pin is reading 5v, when the button is pressed it reads 0v. So that issue has been fixed, a few more to go 8). I will redesign and get back to you and confirm everything is correct. However, for now, do you see anything I could do try to fix it and make It correct, such as changing capacitor values. Or does to need a whole redesign for it to work correctly.
I've changed the resistor value for the main power on LED to 10k and tried lowering the capacitor values to 100nF, as close as I could get to 22pF with the current components I have, It showed no difference.

That's a good job on the reset button, without fixing that it was never going to work.
At the moment you can't really do anything without the correct value capacitors for the crystal- 100nF is still 100000pF, which is way outside of spec for the crystal.

On the redesign, everything looks good except for the missing 100nF decoupling capacitors on the VCC/AVCC pins. I'd also pay careful attention to the layout- the crystal should be close to the microcontroller, rather than across the other side of the board.