Burning bootloader on Atmega using Arduino Errors

Hi Xyver,

  1. You did include resistors in series with the LEDs, didn't you?

  2. The only schematic I can find using ArduinoISP has the LEDs wired from the pins to ground (not +5v), through 330 ohm resistors. So it looks like your LEDs will be on when they should be off, and vice versa.

Yes, the resistors are in series with them, i know at least that much about electronics xD

Regardless if they are in backwards or not, they are solid. No flickers at all. So either they are solid off, or solid on, and from the sounds of it, they are supposed to be blinking.

Xyver: Yes, the resistors are in series with them, i know at least that much about electronics xD

I didn't mean to insult you, but I did wonder when you said "Negative leg in the pin, positive leg to the 5v."

Xyver: Regardless if they are in backwards or not, they are solid. No flickers at all. So either they are solid off, or solid on, and from the sounds of it, they are supposed to be blinking.

Not necessarily. I have a system in which a LED is normally off but is turned on for a 3ms pulse occasionally, perhaps once a second. The pulse can be seen very clearly. But if I had the LED normally on, I doubt I would be able to tell if it went off for 3ms. So if your LEDs appear to be solidly on, you can't assume that they would be solidly off (and not blinking at all) if you had them wired to ground instead of Vcc.

Ah I see. Well, no offence taken :P. Yes, there is the negative lead connected to the resistor, which in turn is connected to the pin. the other side is connected to the 5v.

But, I'll try it with the resistor in the negative, then attached to the negative of the LED, then the positive leg into the pin.

The "not in sync" message sounds to me like either ArduinoISP is running at the wrong baud rate, or the auto-reset is still happening. When you compiled and uploaded the ArduinoISP sketch, are you certain you had the board type set to Arduino, not set to whatever board definition you use for your 8MHz target (if indeed you have a board definition for it)?

If you suspect the auto reset, try using a 10uF capacitor between Reset and GND to disable it - it works for me on the Uno.

When I run ArduinoISP on my Uno, sometimes I have to press the reset button before it works.

When I upload the ArduinoISP program, I have "Arduino duemilanove/nano with ATMEGA 328" selected.

When I connect the resistor (I'll test it with a capacitor as well (.... still error)) to reset, and try to burn the bootloader to the external ATMEGA 328, I select "ATEMGA 328 on a breadboard (with internal 8Mhz clock)"

All in all, same errors as before. Also, I tried reset button before.

How do I check the baud rate?

Try this…

• Locate and open the boards.txt file in the {Sketch}/hardware/breadboard folder

• Locate the following line and put a pound-sign in front…

# atmega328bb.upload.protocol=stk500

• Add the following line right below that line…

atmega328bb.upload.using=arduino:arduinoisp

• Save and close the file. Restart the IDE. Try again to burn the bootloader.

I found these in that file (boards.txt)

atmega328.name=Arduino Duemilanove or Nano w/ ATmega328

atmega328.upload.protocol=stk500 atmega328.upload.maximum_size=30720 atmega328.upload.speed=57600

atmega328.bootloader.low_fuses=0xFF atmega328.bootloader.high_fuses=0xDA atmega328.bootloader.extended_fuses=0x05 atmega328.bootloader.path=atmega atmega328.bootloader.file=ATmegaBOOT_168_atmega328.hex atmega328.bootloader.unlock_bits=0x3F atmega328.bootloader.lock_bits=0x0F

atmega328.build.mcu=atmega328p atmega328.build.f_cpu=16000000L atmega328.build.core=arduino

Its not atmega328bb. Is it the right place?

Its located here C:\Program Files\arduino-0022\hardware\arduino

EDIT:: Nevermind, found it.

EDIT:: Nevermind, found it.

Thank you for posting that. I was just starting my response when you updated your post.

AUGHHHH its trolling me. Everything I do, its taking longer and longer to post the error message, so I think that I'm getting it right.

Still have this: avrdude: stk500_getsync(): not in sync: resp=0x00 avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

Putting either the resistor between 5v and reset gives me one message: avrdude: stk500_getsync(): not in sync: resp=0x15 Putting it between GND and reset gives me the two above Putting a capacitor between Gnd and reset gives me only one as well: avrdude: stk500_getsync(): not in sync: resp=0x15

EDIT:: HOw sensitive are the 328's to static? I dont have a static bracelet or anything, I'm trying to be really careful with them and ground myself before using them, is there any chance that I;m frying them, and its not reading them because they are burned? So it says "not in sync" because its trying to connect with something that it thinks isnt there?

HOw sensitive are the 328's to static?

I have accidentally zapped one and it seems to be fine.

I dont have a static bracelet or anything, I'm trying to be really careful with them and ground myself before using them

Then it is very unlikely that they have been damaged by static electricity.

is there any chance that I;m frying them, and its not reading them because they are burned?

No. The fuses may be changed to a state that requires a crystal but you are not damaging them.

So it says "not in sync" because its trying to connect with something that it thinks isnt there?

The error messages produced by AVRDUDE are unfortunately rather cryptic. Essentially, AVRDUDE is not communicating with the programmer (your Duemilanove running Arduino ISP). Or, AVRDUDE is not communicating with the target processor.

Did you get the LEDs wired the right way around? Right after uploading the Arduino ISP sketch, is one LED fading brighter then dimmer while the other two LEDs or off?

The yellow (pin 7, in communication with the slave) is on always, and the green (hearbeat) is beating away.

When I tell it to burn to the boot loader, they both go off for a sec, then when the error message appears, they return to normal. (yellow on, green beating.)

EDIT:: Someone (probably you) told me this:

First, make certain you can run AVRDUDE from the command-line. In my case, I have to do this…

Code:
set PATH=%PATH%;C:\Arduino\arduino-0022\hardware\tools\avr\utils\bin
set PATH=%PATH%;C:\Arduino\arduino-0022\hardware\tools\avr\bin
set PATH=%PATH%;C:\arduino\arduino-0022\hardware\tools\avr\etc

And I asked where to put it in the code, and noone answered. Where do I put it? In the setup?

EDIT:: Red, (pin 8, error) does not turn on at all.

Xyver: When I tell it to burn to the boot loader, they both go off for a sec, then when the error message appears, they return to normal. (yellow on, green beating.)

Excellent. That indicates that the Arduino ISP sketch is running and that auto-reset has been disabled.

Operating system?

I have a Mac, running windows with bootcamp. I am using windows 7.

EDIT:: There is a very important question to ask though.... When I program the ATMEGA 328 like this, how many pins are available to be used as I/O? The arduino only has 20... and i need 22, and the atmega 328 has 23 potential.

set PATH=%PATH%;C:\Arduino\arduino-0022\hardware\tools\avr\utils\bin
set PATH=%PATH%;C:\Arduino\arduino-0022\hardware\tools\avr\bin
set PATH=%PATH%;C:\arduino\arduino-0022\hardware\tools\avr\etc

Are executed in a command shell to adjust the path so you can run AVRDUDE without having to include directories. You may not have to adjust the path; it is possible the appropriate Arduino directories are already included. You will have to change “C:\Arduino\arduino-0022” to the base directory where you have Arduino installed. The end result is that you should be able to type “avrdude” followed by pressing the Enter key to run AVRDUDE. The output will look something like this…

Usage: avrdude [options]
Options:
  -p <partno>                Required. Specify AVR device.
  -b <baudrate>              Override RS-232 baud rate.
  -B <bitclock>              Specify JTAG/STK500v2 bit clock period (us).
  -C <config-file>           Specify location of configuration file.
  -c <programmer>            Specify programmer type.
  -D                         Disable auto erase for flash memory
  -i <delay>                 ISP Clock Delay [in microseconds]
  -P <port>                  Specify connection port.
  -F                         Override invalid signature check.
  -e                         Perform a chip erase.
  -O                         Perform RC oscillator calibration (see AVR053).
  -U <memtype>:r|w|v:<filename>[:format]
                             Memory operation specification.
                             Multiple -U options are allowed, each request
                             is performed in the order specified.
  -n                         Do not write anything to the device.
  -V                         Do not verify.
  -u                         Disable safemode, default when running from a script.
  -s                         Silent safemode operation, will not ask you if
                             fuses should be changed back.
  -t                         Enter terminal mode.
  -E <exitspec>[,<exitspec>] List programmer exit specifications.
  -x <extended_param>        Pass <extended_param> to programmer.
  -y                         Count # erase cycles in EEPROM.
  -Y <number>                Initialize erase cycle # in EEPROM.
  -v                         Verbose output. -v -v for more.
  -q                         Quell progress output. -q -q for less.
  -?                         Display this usage.

avrdude version 5.10, URL: <http://savannah.nongnu.org/projects/avrdude/>

Yup... I open the CMD, type avrdude, and all that appears.

What about the baud rate?

EDIT:: What about baud rate, as in someone mentioned that a different baud rate might be being used. HOw do I check that?

If you want to use 22 i/o pins in your target system, then I suggest you program the chip directly with the required program and don't use the bootloader. If you burn the bootloader using standard settings, the clock fuse bits will get programmed so that in future you need a crystal, robbing you of two I/O pins.

I've done this and I wrote up how I did it at http://miscsolutions.wordpress.com/2011/08/09/prototyping-small-embedded-projects-with-arduino/. The important thing is to include a 6-pin ICSP header on your target hardware and choose carefully how you use the i/o pins that double up as ICSP pins, then you can reprogram the device in-situ. However, you should also be able to program the device using your breadboard setup - the connections you have between your Arduino and the target device on the breadboard should be the same as the ones you get using the 6-pin cable as per my instructions.

The baud rate passed to avrdude when programming is defined in file C:\arduino-0022\hardware\arduino\programmers.txt. The arduinoisp section should include the following line:

arduinoisp.speed=19200

... SO after all this, how many I/O pins will be available? 23 total, minus the crystal that uses 2, so down to 21?

EDIT:: I need to run 5 RGB LED's (15 digital outputs), 6 pushbuttons (6 digital inputs), and one microphone (analogue input) for a total of 21 digital I/O's, and 1 analogue input. Is there anyway to use that on less pins?

the clock fuse bits will get programmed so that in future you need a crystal, robbing you of two I/O pins

Nope. The fuse settings for “ATmega328 on a breadboard (8 MHz internal clock)” are…

Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 65 ms; [CKSEL=0010 SUT=10]; default value
Boot Reset vector Enabled (default address=$0000); [BOOTRST=0]
Boot Flash section size=1024 words Boot start address=$3C00; [BOOTSZ=01]
Serial program downloading (SPI) enabled; [SPIEN=0]
Brown-out detection level at VCC=2.7 V; [BODLEVEL=101]

…leaving the XTAL pins free.