Dangerous Prototypes

Dangerous Prototypes => Bus Pirate Support => AVRDude => Topic started by: jamesC4S on October 23, 2011, 05:27:20 am

Title: Another avrdude: initialization failed, rc=-2
Post by: jamesC4S on October 23, 2011, 05:27:20 am
I have a PCB coming back with a TQFP ATmega328.  I was hoping to program it using the bus pirate.  As a practice run, I thought I'd try programming my Arduino Uno's ATmega328. 

I have connected all of the signals between the bus pirate and the arduino's ISP header with jumper wires.  I have rechecked the connections multiple times.  From the BP, I can hold the Arduino in reset.  I can also control it with the power supply commands.  These steps have given me some confidence that I didn't get confused on the connections.  I have also tried (as a troubleshooting step) of swapping MOSI and MISO.

Ignoring the Arduino IDE for a moment, here is the output I am getting from avrdude:
Code: [Select]
james-MBP2b:~ james$ avrdude -c buspirate -P /dev/tty.usbserial-A6005lHR -p m328p -v

avrdude: Version 5.11.1, compiled on Oct 21 2011 at 22:58:36
        Copyright (c) 2000-2005 Brian Dean,
        Copyright (c) 2007-2009 Joerg Wunsch

        System wide configuration file is "/usr/local/etc/avrdude.conf"
        User configuration file is "/Users/james/.avrduderc"
        User configuration file does not exist or is not a regular file, skipping

        Using Port                    : /dev/tty.usbserial-A6005lHR
        Using Programmer              : buspirate
        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
          flash        65    6  128    0 yes    32768  128    256  4500  4500 0xff 0xff
          lfuse          0    0    0    0 no          1    0      0  4500  4500 0x00 0x00
          hfuse          0    0    0    0 no          1    0      0  4500  4500 0x00 0x00
          efuse          0    0    0    0 no          1    0      0  4500  4500 0x00 0x00
          lock          0    0    0    0 no          1    0      0  4500  4500 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 : BusPirate
        Description    : The Bus Pirate

Detecting BusPirate...
avrdude: buspirate_readline(): #
avrdude: buspirate_readline(): RESET
avrdude: buspirate_readline():
** 
avrdude: buspirate_readline(): Bus Pirate v3b
**  Bus Pirate v3b
avrdude: buspirate_readline(): Firmware v5.10 (r559)  Bootloader v4.4
**  Firmware v5.10 (r559)  Bootloader v4.4
avrdude: buspirate_readline(): DEVID:0x0447 REVID:0x3043 (24FJ64GA002 B5)
**  DEVID:0x0447 REVID:0x3043 (24FJ64GA002 B5)
avrdude: buspirate_readline():
** 
avrdude: buspirate_readline(): HiZ>
**
BusPirate: using BINARY mode
BusPirate binmode version: 1
BusPirate SPI version: 1
avrdude: initialization failed, rc=-2
        Double check connections and try again, or use -F to override
        this check.

BusPirate is back in the text mode

avrdude done.  Thank you.

BP's Self-test passes with 0 errors.

Host is running OSX 10.6.8.

I'm open to suggestions on how to make this work.
Title: Re: Another avrdude: initialization failed, rc=-2
Post by: jamesC4S on October 23, 2011, 05:41:04 am
I should mention, I also ran with the -F override, which yields:

Code: [Select]

Detecting BusPirate...
** 
**  Bus Pirate v3b
**  Firmware v5.10 (r559)  Bootloader v4.4
**  DEVID:0x0447 REVID:0x3043 (24FJ64GA002 B5)
**  http://dangerousprototypes.com
**
BusPirate: using BINARY mode
avrdude: initialization failed, rc=-2
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
Title: Re: Another avrdude: initialization failed, rc=-2
Post by: tayken on October 23, 2011, 05:41:29 pm
OK, can you try to load an Arduino bootloader to it by using Bus Pirate from Arduino IDE (http://http://taylanayken.wordpress.com/2011/05/04/using-bus-pirate-with-arduino-ide/)? I had problems while writing directly with avrdude but managed to get it working with Arduino IDE. Just select a suitable board from the boards list.
Title: Re: Another avrdude: initialization failed, rc=-2
Post by: ian on October 26, 2011, 03:20:41 pm
I have done some testing now, and I think there is something up with the latest AVRdude. There was a patch, and then another patch, and I wonder if something has gone wrong. I can't see any differences in the Bus Pirate source that would cause it to stop working suddenly after so many success stories. However, I'm likely to blame too :)

Please let me know if the IDE works, then we could be on to something.
Title: Re: Another avrdude: initialization failed, rc=-2
Post by: jamesC4S on October 27, 2011, 12:55:45 am
I'm not sure I understand why this made a difference.  Ian, since you suggested that it could be the latest version of AVRdude, I decided to try older versions.

Started with 5.8 which didn't have the buspirate option.  Went to 5.9 which worked and as it turns out now so does 5.10 and 5.11.  I did a make uninstall in between versions.  I'm not sure why AVRdude is communicating now.
Title: Re: Another avrdude: initialization failed, rc=-2
Post by: ian on November 01, 2011, 03:40:23 pm
Thanks for the update, that is strange. It's good to know the Bus Pirate is working, but it would be better to figure out why AVRDude works inconsistently :/
Title: Another avrdude: initialization failed, rc=-2
Post by: jamesC4S on November 01, 2011, 05:44:37 pm
If it happens again, I'll take better notes.  However, I have been using the BP the past couple of days to debug a new PCB and haven't had any issues with avrdude since it started working.

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01072078856session_write_close ( )...(null):0
20.01102210448ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01102211224Database_MySQL->query( ).../DatabaseHandler.php:119
40.05542349960Database_MySQL->error( ).../Db-mysql.class.php:273