Programming 328P w/AVR Studio error...

My intention is to use AVR Studio and an AVR Dragon to put a fresh bootloader on a 328P (custom arduino board). Some debugging later, I'm down to creating a small project to flash an LED, then burn that to the board, but the programmer says there are errors...

Getting ISP frequency parameters.. SD=0x03 .. OK Setting device parameters.. OK! Entering programming mode.. OK! Erasing device.. OK! Programming FLASH .. OK! Reading FLASH .. OK! WARNING: FLASH byte address 0x0000 is 0x00 (should be 0x0C).. FAILED! Leaving programming mode.. OK!

Any clues where to go from here? Closest post I could find is this (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1250966476), but I don't have another arduino to create a programmer, and surely I should be able to do this with AVR Studio and a Dragon, correct?

Thanks, -Neil.

Does the Dragon work? Have you used it to program other chips?

What is the provenance of the 328P? Was it pulled from an old toy moldy toy? Purchased new?

but I don't have another arduino to create a programmer

Do you have an Arduino and a breadboard?

Chip is brand new. I have no other Arduino currently... had a Pro Mini, but that too is dead. Since my first post above, I've dug up an ATtiny85, and getting the same thing (yes, I recompiled the project for ATtiny85).

So now I suspect my programmer... which btw is new. I'm not sure if there's some fuse setting I need to change perhaps?

Was really hoping to get a ton of this stuff moving over this weekend :(

I'm coming from the PIC world, so perhaps I can find a link to an site where someone was able to use a Pickit2 to program an AVR.

FWIW... I checked all other connections and verified (ohmmeter) that all wires were good.

Are you using the ISP interface?

As far as I can tell, the Dragon ISP does not provide power to the target. How are you powering the target chip?

Yes, ISP.

The dragon is providing power -- it comes from a separate header, and I'm seeing 4.98V across Vcc/Gnd at the chip.

I found this, which I'll try in a bit... http://pickit2.isgreat.org/. Still have to verify it supports any of my chips though.

so perhaps I can find a link to an site where someone was able to use a Pickit2 to program an AVR.

That would be quite the trick, but I suspect that to be made to work it would then no longer be a Pickit2 and not handle pic chips.

Lefty

Wow! The PK2AVRISP works with the Pickit2! I am now able to successfully program the ATtiny85.

I also verified that I can use the Pickit2 for PIC’s still (apparently it’s using the direct “bit-banging” mode of the Pickit2). If it did not, no problem anyway, cause I could always re-flash it, plus I have a couple more Pickit2’s laying around.

Now to the original problem at hand… flashing the bootloader on the 328P. I can read the chip signature (I get Reading signature … 0x1E, 0x95, 0x0F … OK!). But programming the chip still fails with …

Getting isp parameter… SD=0x03 … OKOK
Reading FLASH input file… OK
Setting mode and device parameters… OK!
Entering programming mode… OK!
Erasing device… OK!
Programming FLASH … OK!
Reading FLASH … OK!
WARNING: FLASH byte address 0x7806 is 0xFF (should be 0x51)… FAILED!
Leaving programming mode… OK!

The higher address for the failure seems to indicate that it’s at least getting something done. I may guess that it’s trying to program to an invalid memory location, cause I’m not sure if I even have the correct bootloader for the ProMini 5V/16Mhz. I’m using …\arduino\bootloaders\atmega\ATmegaBOOT_168_atmega328.hex . Need to investigate this more.

Happy Holidays!

According to boards.txt that seems like the correct bootloader.

pro5v328.name=Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328

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

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

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

At this point you should be able to burn the bootloader using the Arduino IDE. Have you tried that?

Happy Holidays to you!

Hmmm... totally did not think of trying it with the Arduino IDE. Will do tomorrow when I'm back at the Arduino.

Lefty: I had skipped past that boards.txt file previously, but just looking at it now. Looks like I'll need this to change processor freqs later. Where would I find the doc that explains the procedure for making these types of changes? Yes, I know I'm getting ahead of myself.

Thanks for the help. -Neil.

Where would I find the doc that explains the procedure for making these types of changes?

Well in context for using the Arduino IDE to compile sketches, the speed has to be defined for both software and hardware and both are defined in the boards entres in the boards.txt file. The software part is handled by the definition of the f_cpu value, this value is used by all the software functions and libraries needing to know about the processors raw clock speed. In hardware some of the fuse settings bits defined in boards.txt set up the processor chip to turn off the internal 8mhz clock and instead utilize the oscillators pins and to expect to have a hardware clock (via external crystal or resonator) wired to those pins to provide the matching clock speed for the processor.

Lefty

There's some documentation of the boards.txt format here: http://code.google.com/p/arduino/wiki/Platforms