stk500v2_command(): unknown status 0xc9

Hello,

I’m stuck and disappointed…

I just received my first Baby-O (B-328) & PGM03A USB AVR programmer
I soldered the pins, and tried to upload a sample program

I wrongly assumed that the power was coming from USB, so at first I tried to program the Baby-O without power…
later, I found out that it was probably a bad idea…because of some fuses…

I read about changing the delays or ISP frequencies…which I think I can achieve using the -B and -i options of avrdude V5.8
I read about checking the connection, I did using a voltmeter and confirmed that each of the 6 pins connect to the controller or to some capacitor component
still no luck…

The funny thing though is that I get the same error, whether the Baby-O is connected or not
-The Baby-O has the green light
-The Programmer has a green light and the flashing yellow
…after avrdude I get the solid red and a flashing yellow

I’m stuck and require some help !

Here is more…

suse-linux:/home/libpololu-avr/examples/atmega328p/led1 # avrdude -i 10000 -B 1000  -e -p m328p -c avrisp2 -P /dev/ttyACM0 -U flash:w:test.hex -v -F

avrdude: Version 5.8, compiled on Dec  1 2009 at 00:28:17
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

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

         Using Port                    : /dev/ttyACM0
         Using Programmer              : avrisp2
         Setting bit clk period        : 1000.0
         Setting isp clock delay        : 10000
avrdude: stk500v2_set_sck_period(): p = 1000.0 us too large, using 276.7 us
         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     5     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 : STK500V2
         Description     : Atmel AVR ISP mkII
         Programmer Model: AVRISP
         Hardware Version: 15
         Firmware Version Master : 2.10
         Vtarget         : 0.0 V
         SCK period      : 106.4 us

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_command(): unknown status 0xc9
avrdude: stk500v2_program_enable(): cannot get connection status
avrdude: initialization failed, rc=-1
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

avrdude done.  Thank you.

Hello, pmichel.

If you tried to program the Baby Orangutan without power it should not have damaged it because the programmer can detect whether the target device has power or not, and it will not attempt to enter programming mode if there is no power.

I think your problem is with the -B argument, which sets the programmer’s ISP frequency.

The way avrdude works is that if you don’t specify the -B argument, it won’t change the frequency, so the programmer will just use whatever frequency it was last set to. This would have worked for you because the USB AVR programmer’s default ISP frequency is 200 kHz, which works fine for Baby Orangutans.

When you ran “avrdude -B 1000 …”, avrdude set the programmer to the slowest possible frequency, 1.5 kHz. This might be causing your problem. The frequency is stored in persistent memory, so you can’t just unpower the programmer to fix it. You should try running this command, which will set the frequency to 200 kHz and erase your mega328:

avrdude -B 3 -c avrisp2 -p m328p -P /dev/ttyACM0 -e

After you run this command, subsequent commands should work without the -B argument, indefinitely.

We usually don’t supply the -B argument. But if you want to do it, then here are valid values which should all work for you: 1 corresponds to 1500 kHz, 2 corresponds to 750 kHz, and 3 corresponds to 200 kHz. The higher the frequency, the faster your Baby Orangutan will program. Unfortunately, the highest frequency (2000 kHz) is not available in avrdude because it considers 0 to be an invalid argument.

I’m not sure what the “-i” argument to avrdude is, but it is not needed so I recommend not using it.

-David

Also, I see you were trying to program one of our led examples. In the future, you can just type “make program” (after you fix your programmer’s ISP frequency).

–David

Thanks for your time David,

To answer your comment,
yes I did use “make program” at first and it didn’t work, thus I read the forum and saw many articles about the ISP frequency…
I then went full manual with avrdude…

After a good night sleep, I was ready to look at MOSI MISO with the big guns (an oscilloscope) but first I wanted to recheck the pins to know which pins to probe…

I then figure out the problem…
I didn’t see the little arrow pointing to pin one on the Baby-O
: /
Again, I assumed the flat cable would go the other way… to have the programmer’s flat cable go over the POT and the LEDs was wrong in my mind

It’s a good thing that the connector can be inverted without blowing anything

I still get an error, but at least I can program the Baby-O

suse-linux:/home/libpololu-avr/examples/atmega328p/analog1 # make program
avrdude -v -p m328p -c avrisp2 -P /dev/ttyACM0 -U flash:w:test.hex

avrdude: Version 5.8, compiled on Dec  1 2009 at 00:28:17
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

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

         Using Port                    : /dev/ttyACM0
         Using Programmer              : avrisp2
         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     5     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 : STK500V2
         Description     : Atmel AVR ISP mkII
         Programmer Model: AVRISP
         Hardware Version: 15
         Firmware Version Master : 2.10
         Vtarget         : 0.0 V
         SCK period      : 59.7 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.07s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as F6
avrdude: safemode: hfuse reads as D9
avrdude: safemode: efuse reads as 4
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "test.hex"
avrdude: input file test.hex auto detected as Intel Hex
avrdude: writing flash (586 bytes):

Writing | ################################################## | 100% 13.09s

avrdude: 586 bytes of flash written
avrdude: verifying flash memory against test.hex:
avrdude: load data flash data from input file test.hex:
avrdude: input file test.hex auto detected as Intel Hex
avrdude: input file test.hex contains 586 bytes
avrdude: reading on-chip flash data:

Reading |                                                    | 0% 0.00savrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500v2_recv(): buffer too small, received 32 byte into 32 byte buffer
Reading | ######################                             | 43% 5.59savrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500v2_recv(): buffer too small, received 32 byte into 32 byte buffer
Reading | ################################################## | 100% 12.80s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x33 != 0x00
avrdude: verification error; content mismatch

avrdude: safemode: lfuse reads as F6
avrdude: safemode: hfuse reads as D9
avrdude: safemode: efuse reads as 4
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

make: *** [program] Error 1
suse-linux:/home/libpololu-avr/examples/atmega328p/analog1 #

That’s good that you realized that you were plugging the programming cable in backwards. It was going to be the next thing I suggest to check.

Based on your AVR dude output, it looks like you are still programming at a very slow speed (13.09s for just 586 bytes of flash). At that rate, it will take you over ten minutes to program your Baby Orangutan if you ever get close to the filling the 32KB of flash. I suggest running avrdude with “-B 1” or “-B 3” just once to switch to a better speed so it will never take more than a few seconds to program your AVR. Also, it might fix your other problem:

It looks like after avrdude writes the flash, it is trying to read it back to verify it, but the programmer is not responding to its commands. This can happen if the programmer leaves programming mode in the middle of programming. That can happen under two conditions: either your target VCC dropped below its acceptable level (unlikely if you can reliably program the AVR), or no programming commands were sent for more than one third of a second. I think that the latter effect is the likely cause of your problem. Perhaps there is a long delay in avrdude after the last write command and before the first read command? You should try fixing your ISP frequency because that might have something to do with this.

-David

You were right,
I just did -B 3 once,
and now it downloads real fast, and I get no more errors

Thanks

…let the fun begin !