Go Down

Topic: Avrdude is wildly unpredictable with my AVR ISP mkii (Read 2927 times) previous topic - next topic

Noah-

Hi everyone.  

I am trying to customize the display of my Seven Segment Display with Arduino 1.0.5 and an AVR ISP mkII.  It was a little bit of a hassle to get it all working together, but I have successfully uploaded an example sketch to the microcontroller so I believe that my set-up is in order.

My problem is, uploading software sometimes takes about a second--but other times it takes about 5 minutes.  Sometimes it doesn't even work at all.  

When the upload takes a long time, this is the (verbose) output of the upload process:
Code: [Select]

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
        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                    : usb
        Using Programmer              : stk500v2
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200159039
avrdude: usbdev_open(): using read endpoint 0x82
avrdude: Sent: . [01]


And then it just sits.  Sometimes it will recover after some delay and quickly send the rest of the data.  Other times it will fail.  Here's the most recent outcome (a failure):

Code: [Select]

avrdude: Sent: . [01]
avrdude: usbdev_recv_frame(): usb_bulk_read(): usb_reap: timeout error
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: Sent: . [01]
avrdude: usbdev_recv_frame(): usb_bulk_read(): usb_reap: reaping request failed, win error: The I/O operation has been aborted because of either a thread exit or an application request.


avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: Sent: . [01]
avrdude: Recv: . [01] . [00] . [0a] A [41] V [56] R [52] I [49] S [53] P [50] _ [5f] M [4d] K [4b] 2 [32]
avrdude: stk500v2_getsync(): found AVRISP mkII programmer
        AVR Part                      : ATMEGA328P
        Chip Erase delay              : 9000 us
        PAGEL                         : PD7
        BS2                           : PC2
        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  3600  3600 0xff 0xff
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

        Programmer Type : STK500V2
        Description     : Atmel STK500 Version 2.x firmware
        Programmer Model: AVRISP mkII
avrdude: Sent: . [03] . [90]
avrdude: usbdev_recv_frame(): usb_bulk_read(): usb_reap: reaping request failed, win error: The device is not connected.


avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: usbdev_send(): wrote -5 out of 1 bytes, err = usb_submit_async: submitting request failed, win error: The device does not recognize the command.


avrdude: stk500_send_mk2(): failed to send command to serial port


What can I do to make this process more reliable?

HugoPT

Quote
avrdude: Sent: . [03] . [90]
avrdude: usbdev_recv_frame(): usb_bulk_read(): usb_reap: reaping request failed, win error: The device is not connected.

Try in another computer to see what happens.It seems the usb somehow gets missing
Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

Noah-

I ended up just writing a batch file to kill avrdude when it hangs.  Just make a new text file, add this code and then save it as a .BAT file:

Code: [Select]
taskkill /f /im avrdude.exe

Whenever uploading is stuck, I just double-click this batch file and try again.  Fun times.

fungus

I put a reset button on my ISP programmer. It resets the internal AVR chip when the USB gets messed up. It's well worth doing...

You can see it below, glued to the top of the USB socket:

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

dc42

1. What else do you have connected to the pins used by ICSP, i.e. the RESET, SCLK, MOSI and MISO pins of the AVR chip?

2. What clock rate are you running the AVR chip at?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Noah-


1. What else do you have connected to the pins used by ICSP, i.e. the RESET, SCLK, MOSI and MISO pins of the AVR chip?


Its being connected to a bog-standard Arduino-Compatible Uno from Sainsmart at the moment, but it has done this with a real Arduino Uno and the arduino inside of a Sparkfun Seven Segment display.  Since it happens consistently whenever I use the ISP with Arduino 1.0.5 I feel like it is not the fault of any of these pieces of hardware.


2. What clock rate are you running the AVR chip at?

I'm not sure how to answer this question!  Here's everything avrdude tells me about the programmer:
Code: [Select]
       Using Port                    : usb
        Using Programmer              : stk500v2
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200159039
avrdude: usbdev_open(): using read endpoint 0x82
avrdude: Sent: . [01]
avrdude: Recv: . [01] . [00] . [0a] A [41] V [56] R [52] I [49] S [53] P [50] _ [5f] M [4d] K [4b] 2 [32]
avrdude: stk500v2_getsync(): found AVRISP mkII programmer
        AVR Part                      : ATMEGA328P
        Chip Erase delay              : 9000 us
        PAGEL                         : PD7
        BS2                           : PC2
        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  3600  3600 0xff 0xff
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

        Programmer Type : STK500V2
        Description     : Atmel STK500 Version 2.x firmware
        Programmer Model: AVRISP mkII
avrdude: Sent: . [03] . [90]
avrdude: Recv: . [03] . [00] . [01]
avrdude: Sent: . [03] . [91]
avrdude: Recv: . [03] . [00] . [01]
avrdude: Sent: . [03] . [92]
avrdude: Recv: . [03] . [00] . [17]
        Hardware Version: 1
        Firmware Version Master : 1.23
avrdude: Sent: . [03] . [94]
avrdude: Recv: . [03] . [00] 3 [33]
        Vtarget         : 5.1 V
avrdude: Sent: . [03] . [98]
avrdude: Recv: . [03] . [00] . [06]
        SCK period      : 8.00 us

avrdude: Sent: . [10] . [c8] d [64] . [19]   [20] . [00] S [53] . [03] . [ac] S [53] . [00] . [00]
avrdude: Recv: . [10] . [00]
avrdude: AVR device initialized and ready to accept instructions

dc42

So the problem happens when trying to program an Arduino (not a standalone atmega328p) via the main ICSP header, and the Arduino is not connected to anything else. So it can't be due to loading of the SCLK, MISO or MOSI pins. It could be related to the capacitor on the Arduino board that is connected between the RESET pin and the DTR output from the usb-to-serial converter. This capacitor will make it difficult for the ISP to pull the reset pin low. You could cut the trace labelled RESET_EN on the board to see if that is the problem - you can always re-make the connection later using the solder bridge provided. [Maybe this is why they included that solder bridge?] I've never tried to program an Arduino via ICSP, I use ICSP to program my own designs.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Noah-

I usually do the same, but I have had a few instances where it wasn't possible to use the conventional Arduino USB cable approach. 

With the 7-Seg, it didn't have a built in ttl-to-serial converter, and this knock-off sainsmart arduino won't program the normal way for reasons that I assume relate to the reset logic not working.

westfw

Quote
this knock-off sainsmart arduino won't program the normal way

So a non-working clone continues to not work very well when used with avrdude?  That doesn't seem particularly surprising.  Perhaps it has something significantly wrong with it?

Have you tried burning the old (long-timeout) bootloader, and using it with manual reset?

Noah-

But it is not working in a way  that all previous arduinos have also not worked!  I haven't tried the manual upload of an old bootloader but I will certainly consider it in the future. 

Noah-

I'm not sure if this is a coincidence or not, but I recently started using a different USB cable and it has been working much more consistently. 

Go Up