2
\$\begingroup\$

I'm starting to learn how to program micro controllers. This is my current setup.

enter image description here

When I'm trying to flash a Hello World program with AVRDude I'm getting the following message:

avrdude: initialization failed, rc=-1
     Double check connections and try again, or use -F to override
     this check.

I have checked most of the options in this guide but none of them seem to resolve this issue. Also using the 16MHz crystal does not help.

I wanted to ask you if you could check my setup and also point me to what I'm doing wrong.

Just to make it clear - my development environment is: Debian / Pocket AVR Programmer.

\$\endgroup\$
  • \$\begingroup\$ Can you share us the exact command line you use? Also, is the mentioned error the only output you get? \$\endgroup\$ – jippie Jul 22 '12 at 19:38
  • \$\begingroup\$ sudo avrdude -P usb -c usbtiny -p m328p, and that's the whole output message. \$\endgroup\$ – Lazy Jul 22 '12 at 20:30
  • 1
    \$\begingroup\$ FYI: I never have to use sudo for this If you do, I might be able to help you with a couple of udev rules to fix that, but that's off topic for this question. \$\endgroup\$ – jippie Jul 22 '12 at 20:56
  • 1
    \$\begingroup\$ You're also missing decoupling capacitors at the power supply pins of the microcontroller. Don't leave them out! \$\endgroup\$ – AndrejaKo Jul 22 '12 at 23:46
  • \$\begingroup\$ Try -v for a more verbose output message. \$\endgroup\$ – vsz Apr 9 '14 at 5:38
3
\$\begingroup\$

Well two things, assuming you have the programming pinout correct you're missing loading caps for your crystal and a pullup resistor on the reset pin. As the default behavior on an unprogrammed chip doesn't use the crystal I'm betting it's the missing pullup that's getting you. Take a look at the following page, should clear all of this up.

Arduino on a prototype board

\$\endgroup\$
  • 1
    \$\begingroup\$ Doesn't the programmer control the reset pin? So you won't need a pullup resistor.. \$\endgroup\$ – m.Alin Jul 22 '12 at 19:59
  • 4
    \$\begingroup\$ I also cannot see how the second (lower) power rail is connected. AFAIK the two power rails are not connected on most breadbords. This would mean that GND is not connected to the ATMega. \$\endgroup\$ – hli Jul 22 '12 at 21:13
  • \$\begingroup\$ Can you bring some of the information from your link, the critical information really so that link rot does not damage the site? \$\endgroup\$ – Kortuk Jul 23 '12 at 8:54
1
\$\begingroup\$

Not sure if it is worth an answer, but the formatting will go all wrong in a comment. Allow me to share with you a little batch file I use to program ATtiny's. Tiny's are pretty much the same to program as a Mega. Also notice I use a different programmer (-c), but that shouldn't be the difficulty here.

  • freq AVR clock frequency
  • baud is the baud rate that my programmer likes to communicate on
  • src is the source code that is to be compiled
  • avr the device type to be programmed
  • dev the device as it shows up in dmesg when I connect my programmer. This is actually the setting that I consider odd in your command.
#!/bin/bash

freq=9600000/8
baud=19200
src=main.cpp
avr=attiny13
dev=/dev/ttyUSB1

avr-gcc -g -DF_CPU=$freq -Wall -Os -mmcu=$avr -c -o tmp.o $src &&
avr-gcc -g -DF_CPU=$freq -Wall -Os -mmcu=$avr -o tmp.elf tmp.o &&
avr-objcopy -j .text -j .data -O ihex tmp.elf tmp.hex &&
avrdude -p $avr -cstk500v1 -P$dev -b$baud -v -U flash:w:tmp.hex

You can check the exact device by typing dmesg | tail from a terminal. When I connect my programmer it says:

[816888.277342] usb 2-2.3: FTDI USB Serial Device converter now attached to ttyUSB1

Notice the ttyUSB1 device node name.

Coming to think of it ..., your error message might imply the problem isn't between your PC and the programmer, but between programmer and AVR. The latter case disqualifying my answer entirely.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.