Go Down

Topic: SOLVED: unable to programm Arduino Leonardo after loading unstable programm (Read 13664 times) previous topic - next topic

hoshymann

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:

Code: [Select]

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.

dmjlambert

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. 

hoshymann

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:
Code: [Select]

               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:
Code: [Select]

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

Whandall

Wouldn't 'Arduino as ISP' be a better choice for programmer?
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)

hoshymann

Damn, you're right :smiley-roll-blue:
But changing this setting does not change anything  :'(

dmjlambert

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.   https://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/

hoshymann

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":
http://www.gammon.com.au/forum/?id=11635

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

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! ;)

dmjlambert

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?

hoshymann

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
Code: [Select]

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:
Code: [Select]

(...) 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:
Code: [Select]

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?

dmjlambert

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.

hoshymann

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:
Code: [Select]

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 :/

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

dmjlambert

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.   

hoshymann

You did it!

I changed the following lines of the original programmer in programmers.txt:
Code: [Select]

# 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 :)

I suspect this line to make the difference:
Code: [Select]

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

hoshymann

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

Code: [Select]

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

dmjlambert

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.   

Go Up