Burning Bootloader using Leonardo

I have 2 leonardo boards without bootloader, I’ve been trying a third Leonardo that works to burn bootloader for the past 2 days without success
All I get is programmer is not responding
Unable to open com port for programmer stk500v1

Can someone please help me out

Perhaps. Set your IDE settings or preferences enable show verbose output during download. Give the step by step details of the exact procedure you are using, including what program are you loading on the programmer Arduino, what wiring you do, which Arduino is connected to the computer and with what kind of wire, what selections you make for all the settings in the tools menu. Just pretend we know absolutely nothing about what you are doing (which we don’t). Don’t miss any details of what you are trying. Show a clear photo of the wiring so we can see your solder connections if you have any, and see where the wires connect. Show the full text of what the verbose upload shows in the IDE.

One major point, you must use the ICSP header on the target Leonardo boards, the MISO/MOSI/SCK pins are not wired to any of the other headers.

I actually followed a guide you did ages ago (glad to see you still being active)
I’m connecting via isp header and p10
I flashed the isp example code with the reset 10 line
Selected arduino as isp
Using this layout

I have a Leonardo that will not accept a bootload any more. I suspect the ATMega32U4 is bad due to static damage and I may get around to replacing the MCU. I recommend make sure your software and wiring is good by ensuring you can bootload something else such as a Nano or Uno. If the one Leonardo you have for a programmer is your last working Arduino, then perhaps you can’t do that. The point of that exercise would be to make sure you can bootload something that you know is in working order.

I don’t even think the other boards are damaged to a degree which doesn’t allow bootloader to burn anymore, both got bricked while uploading a sketch which failed
It already fails at communicating with the programmer which is strange despite it being new and already has the isp code flashed

A long time ago, way too long, I made an ICSP programmer using the Atmega32U4, mainly to simplify the circuit due to the native USB. It still performs perfectly.

There is however a problem. Originally we had a programmer option for “Arduino as ISP (ATmega32U4)”. That was removed somewhere along the line for reasons I cannot remember. The normal choice “Arduino as ISP” does not work with the Atmega32U4 (Leonardo).

You have to add an option back to the programmers.txt file found here (I am assuming Windows):

C:\Users\<your user name>\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Below is a listing of my programmers.txt entries showing the “Arduino as ISP” as well as the “Arduino as ISP (ATmega32U4)” options. You will notice the only difference is the protocol option.

arduinoasisp.name=Arduino as ISP
arduinoasisp.communication=serial
arduinoasisp.protocol=stk500v1
arduinoasisp.speed=19200
arduinoasisp.program.protocol=stk500v1
arduinoasisp.program.speed=19200
arduinoasisp.program.tool=avrdude
arduinoasisp.program.tool.default=avrdude
arduinoasisp.program.extra_params=-P{serial.port} -b{program.speed}

arduinoasispatmega32u4.name=Arduino as ISP (ATmega32U4)
arduinoasispatmega32u4.communication=serial
arduinoasispatmega32u4.protocol=arduino
arduinoasispatmega32u4.speed=19200
arduinoasispatmega32u4.program.protocol=arduino
arduinoasispatmega32u4.program.speed=19200
arduinoasispatmega32u4.program.tool=avrdude
arduinoasispatmega32u4.program.tool.default=avrdude
arduinoasispatmega32u4.program.extra_params=-P{serial.port} -b{program.speed}

Saving the above and restarting the IDE also does not work since the programmer options are cached. You need to delete the .arduinoIDE file if I remember correctly.

C:\Users\<your user name>\.arduinoIDE

Close arduino, delete the above file (backup to be safe) and restart the IDE. The deleted file will be recreated but you will loose you settings (like preferences - make a copy).

Quickly pressing the reset button twice should put the board into bootloader mode and allow you to upload a sketch without running the code that is currently on the board.

This programmer definition is still present in the "Arduino AVR Boards" platform. Each boards platform may provide its own programmer definitions, so you won't necessarily have this option under Arduino IDE's Tools > Programmer menu if you have a board from a 3rd party platform (e.g., MiniCore boards platform) selected.

So it should not be necessary for @quisl to modify their programers.txt file in order to accomplish this.

I confirm this. @quisl please make sure to select Tools > Programmer > Arduino as ISP (ATmega32U4) from the Arduino IDE menus. If you had a different option selected previously, please try again after adjusting the Tools > Programmer menu selection.

Update:
Wow the fix was so simple, I had to use Arduino as ISP (ATmega32u4)
Can someone explain why in the past it was just Arduino as ISP
Thanks everyone for helping

Great news!

Background

Arduino IDE uses a tool named AVRDUDE to perform the "Burn Bootloader" operation. AVRDUDE is a general purpose tool intended to support various memory programming operations for the entire range of AVR microcontrollers, via a variety of ISP programmers and bootloaders.

These programmers and bootloaders use a variety of distinct protocols by which the transfer of data between the AVRDUDE application and the target is accomplished. So AVRDUDE must be configured for the specific programmer type in use:

https://avrdudes.github.io/avrdude/7.3/avrdude_4.html#index-Option-_002dc-programmer_002did

There are two different programmer types that can be used with an "Arduino as ISP" programmer:

  • arduino
  • stk500v1

The arduino programmer type can be used with all "Arduino as ISP" programmers, regardless of which specific Arduino board model is used for the programmer. However, use of this programmer type can sometimes result in the programming operation failing when the programmer board has an auto-reset circuit (e.g., UNO R3, Mega 2560, classic Nano). That can be worked around by connecting a capacitor to the board, but this makes an already complex endeavor even more so.

The failure with programmer boards that have an auto-reset circuit is less likely to occur when AVRDUDE is configured to use the alternative stk500v1 programmer type. However, this programmer type can not be used by Windows users when the programmer board uses native USB (as is the case with the Leonardo):

The programmer type used by AVRDUDE when performing a "Burn Bootloader" operation is configured in the programmer definitions of the Arduino boards platform that adds support to Arduino IDE for a given set of Arduino boards/microcontrollers. Support for the Leonardo board is provided by the "Arduino AVR Boards" platform.

History

The "Arduino as ISP" programmer definition in the Arduino AVR Boards platform configured AVRDUDE to use the stk500v1 programmer type in versions 1.6.20 and earlier.

In version 1.6.21, the "Arduino as ISP" programmer definition was changed to instead use the arduino programmer type:

That change allowed Windows users to utilize of native USB boards like the Leonardo, Micro, Pro Micro, etc. as an "Arduino as ISP" programmer. However, we started receiving more reports of failures from people using boards with the auto-reset circuit as "Arduino as ISP" programmers:

For this reason, starting from version 1.8.1 of the Arduino AVR Boards platform, the "Arduino as ISP" programmer definition was changed back to use the stk500v1 programmer type. In order to continue to support the use by Windows users of native USB boards as a programmer, a new "Arduino as ISP (ATmega32U4)" programmer definition was added (ATmega32U4 is the microcontroller on the Leonardo, Micro, and Pro Micro boards):

Analysis

All that said, we circle back to your question:

I'm not sure exactly what you mean by this. I hope the information I provided above answers your question.

If you are asking why there was originally only the one "Arduino as ISP" programmer definition, I think I have covered that well.

If you are instead saying that at some time in the past you were able to perform this same operation using the "Arduino as ISP" programmer definition, then there are several possible explanations:

  • You were using a different board as an "Arduino as ISP" programmer, and that board did not use native USB communication.
  • You were using a native USB board as programmer, but on a computer with an operating system other than Windows.
  • You were using a native USB board as programmer, with an Arduino AVR Boards platform version in the range from 1.6.21-1.6.23.

wow really great explanation, thanks a lot for the effort. Never would have thought to experience this overwhelming amount of support
Really appreciate it everyone​:heart_hands:

so that means i cant program an ATtiny85 with arduino anymore?

No. You are welcome to program an ATtiny85 with Arduino. I don't know how you drew that conclusion from what was written here.

If you want to program an ATtiny85, give it a try. If you encounter a problem, just let use know and we'll provide assistance.

Well I read the "Arduino as ISP" part and I got sad cuz was removed