[SOLVED] ArduinoISP programming Atmega8515 on breadboard

I'm new to the Arduino and just starting to play around with my Mega 2650r3, but one thing I wanted to try out was the ArduinoISP capability to flash an Atmega8515 for another project I'm working on. I have the Intel-format .hex file I wish to flash and I know the pinout for hooking it up, and I've have tried following the tutorial's I've found, but I have a feeling that I'm missing something in the configuration for flashing on a breadboard (preferably the barebones setup without additional components on the board). I can get as far as uploading ArduinoISP to the Mega and then firing up avrdude and initializing the chip, but when I try to flash the actual .hex, it gives me a protocol error. I'll post any more detailed information that may be necessary, but I'm pretty sure I am missing some basic setup, since most of the tutorials I've found are for programming other chips, so I may be incorrectly configured. Any pointers would be greatly appreciated.

EDIT: For anyone reading this later for reference, I ended up wiring up the entire circuit shown here http://arduino.cc/en/Tutorial/ArduinoToBreadboard using an external crystal, the barebones layout did NOT work. I then had to follow this hack Google Code Archive - Long-term storage for Google Code Project Hosting. to get ArduinoISP to play nice. Also, to clear up a couple of things that were not quite clear to me as a noob searching aimlessly on the internet, this does require a 100nF (.1uF) cap across RESET and GND on the Arduino inserted AFTER the ArduinoISP sketch has been uploaded but BEFORE uploading the .hex to the 8515, and the 22pF caps on the crystal recommended in the above linked guide worked fine even though my project manual indicated the need for 27's.

it gives me a protocol error

  • ? -

Sorry, I tried it last night and have since disconnected it. Didn't remember the exact error offhand. I'll hook it back up and post back.

If it happens to be relevant, using the project documentation I have, this is how it's all connected:

MEGA || 8515
MISO 50 7
MOSI 51 6
SCK 52 8
SS 53 9
+5v 40
GND 20

And here's the output of avrdude:

C:\>avrdude -p m8515 -P com7 -c avrisp -b 19200 -U flash:w:gbcf-fw-2.1-usb.hex

avrdude: please define PAGEL and BS2 signals in the configuration file for part
ATMEGA8515
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.14s

avrdude: Device signature = 0x1e9306
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: please define PAGEL and BS2 signals in the configuration file for part
ATMEGA8515
avrdude: reading input file "gbcf-fw-2.1-usb.hex"
avrdude: input file gbcf-fw-2.1-usb.hex auto detected as Intel Hex
avrdude: writing flash (3614 bytes):

Writing |                                                    | 0% 0.00s
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
avrdude: stk500_cmd(): protocol error

Using Arduino IDE 1.0?

I used Arduino IDE to flash the ArduinoISP sketch to the Arduino, then I used avrdude manually from the command-line because I couldn't find any way to program a specified .hex file to a specified microcontroller, only the presets for the Arduino controllers.

Which version of the Arduino IDE did you use to compile the ArduinoISP sketch?

Whatever the latest version was as of a week or so ago. It says 1.0. And I'm using the ArduinoISP sketch that came with it. File>Examples>ArduinoISP

The failure is the result of a bug in the ArduinoISP sketch surfaced by a change in the Arduino IDE 1.0. You can either lower the baud rate to 9600 or send me a Personal Message with your email address and I'll reply with a version that works.

So, I did some more reading, and from what I've seen, I need to disable auto-reset? I read that a 120ohm resistor or 100nm cap bridging from +5v to reset should be sufficient. From what I have on hand, I have an equivalent resistance of ~114ohms across it and here's what I get now:

C:\>avrdude -p m8515 -P com7 -c avrisp -b 19200 -U flash:w:gbcf-fw-2.1-usb.hex

avrdude: please define PAGEL and BS2 signals in the configuration file for part
ATMEGA8515
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x1e9306
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: please define PAGEL and BS2 signals in the configuration file for part
ATMEGA8515
avrdude: reading input file "gbcf-fw-2.1-usb.hex"
avrdude: input file gbcf-fw-2.1-usb.hex auto detected as Intel Hex
avrdude: writing flash (3614 bytes):

Writing |                                                    | 0% 0.00s
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
avrdude: stk500_cmd(): programmer is out of sync

Tried the baud rate change and this is what I got:

C:\>avrdude -p m8515 -P com7 -c avrisp -b 9600 -U flash:w:gbcf-fw-2.1-usb.hex
avrdude: stk500_getsync(): not in sync: resp=0xff

avrdude done.  Thank you.

My email is my username at yahoo, I'll be glad to give the fixed version a try.

Email is on the way.

The version you sent me gives even stranger errors than I was getting before...

C:\>avrdude -p m8515 -P com7 -c avrisp -b 19200 -U flash:w:gbcf-fw-2.1-usb.hex

avrdude: please define PAGEL and BS2 signals in the configuration file for part
ATMEGA8515
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.10s

avrdude: Device signature = 0x1e9306
avrdude: safemode: Verify error - unable to read lfuse properly. Programmer may
not be reliable.
avrdude: safemode: To protect your AVR the programming will be aborted

avrdude done.  Thank you.

It's 1:30am here, so I'm gonna call it a night. But thanks for the help so far. Hopefully, we'll get this sorted...

avrdude -p m8515 -P com7 -c stk500 -v -v -v -b 19200 -U flash:w:gbcf-fw-2.1-usb.hex

I started on another project (musical floppy drives :D) so I've ignored this for awhile, and now that I decided to give it another try, I just accidentally broke off a wire end in the header for MOSI (pin 51). Any ideas for removing a wire that's gotten broken off in the pin header?

There have been two suggestions on the forum: 1. Use a needle. 2. Remove the plastic shroud.

Ok, so I got that sorted out (kinda... it works for now :P). I want to give this another shot, but I'm going to start fresh and make no assumption that I have any idea what I'm doing here. The information I'm going off of originated from http://www.instructables.com/id/How-to-use-Arduino-Mega-2560-as-Arduino-isp/ and http://arduino.cc/en/Tutorial/ArduinoToBreadboard, neither of which actually discusses programming to the 8515, but I'm assuming that the information is still applicable other than pin assignments on the microcontroller itself. My information regarding the 8515 is coming from the project manual for the project I'm actually building

Manual:
http://www.reinerziegler.de/GB-Flasher/gbcflsh_manual.pdf

Schematic:
http://www.reinerziegler.de/GB-Flasher/schem+pcb/GB%20Cart%20Flasher%20(USB).pdf

Ok, so with all of that info, I've attached a picture to show what my board setup looks like (the LED is just a leftover from some other stuff I was working on...)

One thing I've been wondering is, do I need the 100uF cap across RST->GND on the Arduino to prevent auto-reset like I've read several places or is that not an issue? Do I need the external crystal while flashing or can I do it this way? Basically, I just want to make sure there are no errors in my hookup before continuing to hunt down the problem on the software side.

Basically, I just want to make sure there are no errors in my hookup before continuing to hunt down the problem on the software side.

GNDs need to be connected.

Is the target powered close to 5 volts?

One thing I've been wondering is, do I need the 100uF cap across RST->GND on the Arduino to prevent auto-reset like I've read several places?

Yes.

Do I need the external crystal while flashing or can I do it this way?

If the target will be running from an external crystal then you will need to connect the external crystal while flashing.

GNDs need to be connected.

Which GND's? Do I nee to connect the Arduino's GND to the breadboard GND?

Is the target powered close to 5 volts?

The breadboard supply line is connected to an external 5v 1000mA source.

If the target will be running from an external crystal then you will need to connect the external crystal while flashing.

It will be. So I take it that I should be following more closely to the first scenario on the arduino.cc ArduinoToBreadboard guide for breadboard setup, rather than the barebones setup I have now? If so, do I need the capacitors as well and how do I figure out which pins on the 8515 I should be wiring this stuff up to? I'm assuming from the project wiring schematic that the crystal goes between pins 18 and 19, but I have no idea for the capacitors.

qwertymodo:
Which GND's? Do I nee to connect the Arduino's GND to the breadboard GND?

Yes.

The breadboard supply line is connected to an external 5v 1000mA source.

Perfect.

So I take it that I should be following more closely to the first scenario on the arduino.cc ArduinoToBreadboard guide for breadboard setup, rather than the barebones setup I have now?

At the point you change the fuses so the processor runs from the external crystal you will have to have the crystal connected. Until then you can play with the target without connecting the external crystal. The processor leaves the factory ready-to-run.

If so, do I need the capacitors as well

If you are using a crystal then yes. If you are using a resonator then the capacitors are built-in.

and how do I figure out which pins on the 8515 I should be wiring this stuff up to?

Datasheet. The crystal or resonator is connected across XTAL1 and XTAL2 (physical pins 18 and 19).

I'm assuming from the project wiring schematic that the crystal goes between pins 18 and 19, but I have no idea for the capacitors.

The capacitors are connected from the pin to GND.