SOLVED: unable to programm Arduino Leonardo after loading unstable programm

Hey guys,

I am working with a Leonardo for the first time for a few days now.
Everything was working fine until today.

I was trying to implement a buffer of 1000 integers and the compiler warned me about possible problems with stability, because I was using (84% used) of the Leos RAM. "To hell with stability" I thought and uploaded the programm.
After the Leo did not realy produce the desired results, I changed my code and tried to upload it again, but I just got the following error message:

Found upload port: COM12
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -PCOM12 -b57600 -D -Uflash:w:C:\Users\Hockner\AppData\Local\Temp\build43f01c5dd1676eb59a795ecd5e1796a4.tmp/LandesmuseumWB_IR-Sensors.ino.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                    : COM12
         Using Programmer              : avr109
         Overriding Baud Rate          : 57600
         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 : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

By now I tried different USB ports on my machine, different programms to compile and upload and unplugging/restarting the Leo at different times during the compiling/uploading.

Did I break the poor thing?
Or is there a way to get him back on its feet?

Thank you for any ideas!
Mark

EDIT: Oh, forgot to mention, I am using version 1.6.7 of the IDE.

You can try pressing the reset button when the IDE says uploading. You may need to try several times to get the timing right. Sometimes Leonardo-type boards can be a pain to recover from this sort of malfunction. I sometimes end up re-bootloading it to give it a fresh start. I use another Arduino such as an Uno, running the ArduinoISP sketch, to make it an ISP programmer. If you like the ATmega32U4 processor, but want the Uno-like uploading experience where the DTR comes in like an iron fist and darn well resets the processor and runs the bootloader, you can load the Optiboot bootloader on it and use an external FTDI or Bluetooth adapter to program it.

First of all, thank you for the help!

I only have a second Leonardo here, on wich I loaded the ArduinoISP sketch now to turn it into an AVR ISP programmer.
I hooked that programmer Leonardo up to the USB port of my PC and connected it to the second (malfunctioning) Leonardo based on this pin layout:

               MISO °. . 5V (!) Avoid this pin on Due, Zero...
               SCK   . . MOSI
                     . . GND

So I connected MISO with MISO, SCK with SCK, MOSI with MOSI and GND with GND. Also I connected pin 10 of the programmer with the RESET pin of the faulty Leonardo and powered the faulty Leonardo through the power jack with a 9V power adapter.
EDIT: I just remover the power adapter and instead connected the 5V pins of the ICSP port of both Leonardos. With the same results...

In the IDE I set the board to Arduino Leonardo, the programmer to AVR ISP and the port to the one the programmer Leonardo is connected to.

With that setting I tried to "burn bootloader" as well as uploading a random sketch.
In both cases I only get this error:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03

The operation aborts after 10 attempts.

What am I doing wrong?
Is the Leonardo not capable for being used as a programmer?
Do I need to connect the LEDs (with resistor) as suggested in the ArduinoISP sketch?

Thanks again!
Mark

Wouldn't 'Arduino as ISP' be a better choice for programmer?

Damn, you're right :roll_eyes:
But changing this setting does not change anything :cry:

Try this tutorial. I don't know a lot about the IDE on Windows, but I've heard that a custom programmers.txt entry may be needed to use Leonardo as ISP if you have Windows. PeterVH is a regular contributor here, and he does a good job of keeping his tutorials current, so I suspect it still applies. ArduinoISP on the Leonardo | PeterVH

Thank you.
I tried the tutorial you linked above.

But also with the new "Arduino as ISP (Leonardo)" programmer selected, I am not able to programm the fauly Leonardo.
The wiring is exactly as described on this page under "Wiring for Leonardo":

There are no LEDs blinking on any of the Leonardos while I try to burn the bootloader and I always get the same error:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xa5

While the Hex code (resp=...) seems to change every with every try but stays the same during the 10 attempts.

What am I doing wrong? I'm out of ideas, please save me! :wink:

Can you post a photo that shows your wiring clearly? Can you tell exactly what you are selecting in the menu in the IDE step by step as you go through the process of burning the bootloader? In the IDE preferences you can check show verbose output during upload, then post the entire contents of the console at the bottom of the IDE after an attempt. Do you have any other Arduinos, or just the two Leonardos?

I sure can!

wiring:
It all looks a bit crappy because I didn't have enough connectors.

So here is a sketch I drew to show the wiring more clearly.

IDE configuration:

  • opening arduino.cc IDE version 1.6.7
  • File > Preferences > check both "compilation" and "upload" at "Show verbose output during:"
  • Tools > Board > Arduino Leonardo
  • Tools > Port > COM11 (Arduino Leonardo)
  • Tools > Programmer > Arduino as ISP (Leonardo)
    NOTE: This option is only available after adding the following to
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\programmers.txt
arduinoispleo.name=Arduino as ISP (Leonardo)
arduinoispleo.communication=serial
arduinoispleo.protocol=arduino
arduinoispleo.speed=19200

burning the bootloader:

  • Open > 11.ArduinoISP > ArduoniISP
  • Sketch > Upload

console output:

(...) took out all the compiling info to stay inside the limit of 9000 characters per post!

Sketch uses 7,620 bytes (26%) of program storage space. Maximum is 28,672 bytes.
Global variables use 448 bytes (17%) of dynamic memory, leaving 2,112 bytes for local variables. Maximum is 2,560 bytes.
Forcing reset using 1200bps open/close on port COM11
PORTS {COM1, COM3, COM11, } / {COM1, COM3, } => {}
PORTS {COM1, COM3, } / {COM1, COM3, COM10, } => {COM10, }
Found upload port: COM10
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -PCOM10 -b57600 -D -Uflash:w:C:\Users\Hockner\AppData\Local\Temp\build7b27b474b023374a5b7498d9f754d24c.tmp/ArduinoISP.ino.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                    : COM10
         Using Programmer              : avr109
         Overriding Baud Rate          : 57600
         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 : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44

avrdude: devcode selected: 0x44
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9587
avrdude: reading input file "C:\Users\Hockner\AppData\Local\Temp\build7b27b474b023374a5b7498d9f754d24c.tmp/ArduinoISP.ino.hex"
avrdude: writing flash (7620 bytes):

Writing | ################################################## | 100% 0.64s

avrdude: 7620 bytes of flash written
avrdude: verifying flash memory against C:\Users\Hockner\AppData\Local\Temp\build7b27b474b023374a5b7498d9f754d24c.tmp/ArduinoISP.ino.hex:
avrdude: load data flash data from input file C:\Users\Hockner\AppData\Local\Temp\build7b27b474b023374a5b7498d9f754d24c.tmp/ArduinoISP.ino.hex:
avrdude: input file C:\Users\Hockner\AppData\Local\Temp\build7b27b474b023374a5b7498d9f754d24c.tmp/ArduinoISP.ino.hex contains 7620 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.18s

avrdude: verifying ...
avrdude: 7620 bytes of flash verified

avrdude done.  Thank you.
  • Tools > Burn Bootloader

console output:

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega32u4 -carduino {program.extra_params} -e -Ulock:w:0x3F:m -Uefuse:w:0xcb:m -Uhfuse:w:0xd8:m -Ulfuse:w:0xff:m 

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                    : com1
         Using Programmer              : arduino
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x44
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x44
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x44
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x44
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x44
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x44
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x44
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x44
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x44
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x44

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

I am just now wondering that is says "Using Port : com1". Shouldn't it say com11?

hoshymann:
I am just now wondering that is says "Using Port : com1". Shouldn't it say com11?

Yes, I'm kind of thinking that. After you upload the ArduinoISP sketch and before you do Burn Bootloader check the port setting and make sure it is still set on the same port you used to upload the ArduinoISP sketch.

I recommend getting some female to female, male to female, and male to male dupont wires like this.

The port setting does not change and even if I restart the IDE and/or dis- and reconnect the Leonardo and set the port again, it still says "Using Port : com1".

Where can I change that setting?!

For the fun of it, I now tryed to Burn Bootloader with the USB cable to the leonardos unplugged and I got this error:

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega32u4 -carduino {program.extra_params} -e -Ulock:w:0x3F:m -Uefuse:w:0xcb:m -Uhfuse:w:0xd8:m -Ulfuse:w:0xff:m 

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                    : com1
         Using Programmer              : arduino
Error while burning bootloader.
avrdude: ser_open(): can't open device "\\.\com1": access denied



avrdude done.  Thank you.

So is com1 a port inside the Leonardo? I am totaly lost here :confused:

EDIT: The wires are neat. Will try to get some of these. Thanks.

In your post #8 above you show the console output from when you were loading the ArduinoISP sketch onto the working Arduino. That output shows you were using COM11. That is selected on the Menu in Tools, Port.

Then in the same post the next thing you show is console output from when you were running Burn Bootloader. I do see that attempts using COM1, and I think perhaps it is using that by default and the programmers.txt entry you added was not complete enough to work right, and it does not work with the setting you make in the Tools, Port menu. So there must be something wrong with PeterVH's tutorial, perhaps the procedure requires a specific version of the IDE. I'm just speculating...

Anyway, what if you: find the programmers.txt that is part of the IDE installation. Edit the line arduinoasisp.program.protocol=stk500v1 changing it to arduinoasisp.program.protocol=arduino
Then save and quit/restart the IDE and pick on the menu Tools, Programmer, Arduino as ISP
Then try the Burn Bootloader.

You did it!

I changed the following lines of the original programmer in programmers.txt:

# arduinoasisp.protocol=stk500v1	                # original line
arduinoasisp.protocol=arduino		                # changed for Leonardo
# arduinoasisp.program.protocol=stk500v1	#original line
arduinoasisp.program.protocol=arduino		#changed for Leonardo

Now I am able to Burn Bootloader with the "Arduino as ISP" programmer and both of my Loenardos are working again :slight_smile:

I suspect this line to make the difference:

arduinoasisp.program.extra_params=-P{serial.port} -b{program.speed}

And will do some testing to verify and try to make a more complete version of a Leo-Programmer to contribute to PeterVH's tutorial. I will keep you informed in this post anyway.

Thank you so much!
Mark

Allready got it.
The cleaner alternative to changing the "Arduino as ISP" parameters would be to add the following to your programmers.txt

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

This post is solved!
Thanks again!
Mark

Excellent. Glad to hear it. I wonder what the difference between .protocol and .program.protocol is. I have a Mac and a Linux machine, and PeterVH explains in his tutorial why it is needed on Windows only, so I have not encountered this.

Not sure about the difference either.
Maybe .program describes the behavior using a programmer.
I guess .program.extra_params is responsible for the right COM port.

Thanks a lot people, saved my board :slight_smile:
Btw here's a clear wiring picture if anyone needs it for Pro Micro: https://schou.dk/linux/arduino/isp/IMG_5841.JPG

Check this: https://www.dfrobot.com/forum/viewtopic.php?t=216

I was having a load of problems getting a Leonado to upload. It worked on one PC but not the other.
Solution?
Bypass any USB hubs and plug into the PC USB port.
It never used to be a problem and only applied to the Leonado recently, mainly because of the increasing number of USB devices attached.
No other devices are a problem, so the Leonado must be a bit fussy.
I am going to try and work out which of the hubs is causing the problem, but I have a decent 8-port hub (Cambrionix) and some cheepo's daisy-chained off that.
On the plus side, the XBee SerialDump example suddenly came to life after many hours of faffing around.
I'm coming to the conclusion that with USB hubs - all powered incidentally - it's better to have one decent multiport hub and if you have to daisy-chain, then just use them for USB power