How to rewrite bootloadr with STK500v2 to Arduino Leonardo

Hi,
by mistake I selected "Uno" to compile and burn a sketch to a "Leonardo" board.
Since then I get
avrdude error: programmer did not respond to command: exit bootloader
I assume I broke the bootloader and need to re-write it to the "Leonardo".

Q1: Could this wrong selection really kill the bootloader on the Leonardo ?

I do have a STK500v2 board available which I can use to write the bootloader to the "Leonardo" via ISP. But I would need some guidance to do so.

Q2: What are the steps to re-write the bootloader and how to connect the ISP between the two boards ?

Thx for any reply !

Hi @holwei. Please try this experiment and then report back with the results:

  1. Connect the Arduino board to your computer with the USB cable.
  2. Press and release the reset button on the Arduino board.

Now please reply here on the forum thread with the answer to the following question:

  • Do you see the LED marked "L" on the board pulse after performing the above instructions?

Yes, it is pulsing / flashing !

I see in the Arduino IDE, that I can select the STK500 as a "Programmer board".

Do i need to select the "Port=ttyUSB0" where the STK500 is connected and the "Board=Leonardo" to burn the bootloader again ?

The STK500 6-pin ISP connector fits to the Leonardo ISP connector (I hope the pinout is the same) !

But before trying I wan to ensure it is necessary to do so ...

How did you manage that? Via ICSP?

That would mean that the boot loader is functional.

So I would suggest the following steps (assuming it is Linux) to confirm that the boot loader will create a port.

  1. Run dmesg -w with the board connected; the application will not close.
  2. Press <enter> a few times; this is only to be able to easily differentiate between the old output and the new one.
  3. Tap the reset on the Leonardo.
    • Do you get any reaction? Possibly a new /dev/ttySomething (not behind a Linux system at the moment so not sure if it would be ttyACMx or ttyUSBx).

If you got a new port, select that port in the IDE (you might have to repeat the reset exercise). Next perform an upload and when the IDE reports the memory usage tap the reset button to invoke the bootloader.

Upload should now succeed.

No, not via ISP.
I was using the Arduino IDE and pressed the "compile and upload" button in my sketch, but with the "UNO" selected instead the "Leonardo".

The Leonardo is creating a new USB port everytime I press the reset-button:

[ 6070.791233] usb 2-1: Manufacturer: Arduino LLC
[ 6070.791235] usb 2-1: SerialNumber: MIDI
[ 6070.792589] cdc_acm 2-1:1.0: ttyACM3: USB ACM device


[ 6133.387145] usb 2-1: USB disconnect, device number 23
[ 6134.114372] usb 2-1: new full-speed USB device number 24 using xhci_hcd
[ 6134.264251] usb 2-1: New USB device found, idVendor=2341, idProduct=0036, bcdDevice= 0.01
[ 6134.264261] usb 2-1: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[ 6134.264265] usb 2-1: Product: Arduino Leonardo
[ 6134.264268] usb 2-1: Manufacturer: Arduino LLC
[ 6134.265829] cdc_acm 2-1:1.0: ttyACM3: USB ACM device


[ 6139.099602] usb 2-1: USB disconnect, device number 24
[ 6139.642359] usb 2-1: new full-speed USB device number 25 using xhci_hcd
[ 6139.792217] usb 2-1: New USB device found, idVendor=2341, idProduct=0036, bcdDevice= 0.01
[ 6139.792227] usb 2-1: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[ 6139.792231] usb 2-1: Product: Arduino Leonardo
[ 6139.792234] usb 2-1: Manufacturer: Arduino LLC
[ 6139.793626] cdc_acm 2-1:1.0: ttyACM3: USB ACM device
[ 6147.403967] usb 2-1: USB disconnect, device number 25
[ 6147.718367] usb 2-1: new full-speed USB device number 26 using xhci_hcd
[ 6147.871288] usb 2-1: New USB device found, idVendor=2341, idProduct=8036, bcdDevice= 1.00
[ 6147.871299] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 6147.871303] usb 2-1: Product: Arduino Leonardo
[ 6147.871305] usb 2-1: Manufacturer: Arduino LLC
[ 6147.871308] usb 2-1: SerialNumber: MIDI
[ 6147.873079] cdc_acm 2-1:1.0: ttyACM3: USB ACM device

Success - it seems I had selected the wrong USB port !

I am happy that I did not have to rewrite the bootloader and mess around with fuses etc. !

Thanks for your quick support !

1 Like

Does the Leonardo create the new port when using the upload from the ide?

There is a Linux bug related to the Nano Every where the 1200 bps signal to initiate the bootloader does not occur.

The Leonardo bootloader is triggered by the same 1200 baud pulse. Perhaps the Linux issues is relevant to this board as well as the Nano Every.

How can I test it. Would I disconnect and reconnect after a successful write ?

The USB port stays the same after mutliple writes via the IDE.

My issue was what I loaded the sketch on another laptop, and - I do know why - thought that I did programm this Leonardo already succesfully on this laptop - but it was not the case.

I just programmed and did not configure the Board and Port properly.
Then I selected "Leonardo" instead of "Uno" and got the error.

The problem was,t that I did not check if I used the correct USB port.
After your hints, I figured out this was the problem.

The Leonardo can present two USB ports to the operating system.

One port is active during run mode, and the other(bootloader port) is the port active during upload. The bootloader usb port can be activated by the reset button or a 1200 bps pulse to the run mode port. You documented in a previous post the switching between the ports with resets.

When you say you need to "use the correct port" do you mean that you need to manually select the bootloader port to load code, or do you select run mode port, and the Leonardo automatically switches to the bootloader port from the ide?

I use the Leonardo to create a MID device via the "MIDIUSB" lib.

The Leonardo port I use fro programming is "/dev/ttyACM3 (Arduino Leonardo)".
The device I select in MuseScore as MIDI device is "ALSA Arduino Leonardo MIDI 1".

When I reprogram the Leonardo, I have to restart MuseScore to detect the device again, otherwise it fails.

Hope this helps.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.