Go Down

Topic: Atmega328p Programming from Uno (Read 2611 times) previous topic - next topic

ChrisXenon

Hi,

There is a lot of content here and elsewhere on using an Arduino to program an ATMEGA328p, but nothing seems to match my situation and the things I've seen to try don't work for me, so I'm hopeful of finding my answer from you guys, and I hope I have not wasted your time by missing something which should be obvious.

I bought two Atmega328Ps; they came pre-loaded with the Arduino Duemilanove (16MHz) Boot loader.
I have an Arduino Uno R3, which I've loaded with the ArduinoISP sketch (dated July 2011 in the comments).

Minor issue:

The seller of my 328ps says I can just put them in my Uno and tell the IDE it's a Due and it will all work fine.
It seems to, given my limited testing. But how come? It's different hardware, isn't it?

However, the main issue is this.

I am trying and failing to program the AVR from the Uno, using this tutorial:
http://arduino.cc/en/Tutorial/ArduinoToBreadboard, then noticed the note about it not working with Uno.
I tried this one http://arduino.cc/en/Tutorial/ArduinoISP which has no such warning but it doesn't work either.
I've tried them with and without the capacitor from RESET to ground, and I've tried them all selecting Uno, Due and Nano as the target boards.
I tried another method involving removing the chip from the Uno to "allow the FDI to talk to the AVR" no good.
I've also tried to overwrite the bootloader with Uno in case that's the problem but that doesn't work either.

So focussing on the offical tutorial and a specific error. When I use this: http://arduino.cc/en/Tutorial/ArduinoISP
using the bottom-right hookup, I get this: stk500_getsync(): not in sync: resp=0x1c

Wrong board, right? Well, I don't know how to fix it. Any thoughts? Any cast iron methods you can recommend?

In case it's relevant, I have used the Uno as ISP to program Attiny85 without problems.

FYI I have an Atmega board if that offers a useful way out.

Many thanks,
Chris

ChrisXenon

... I just tried it using my Arduino Mega instead of the Uno, making the new pin assignments as per the comments in the sketch.
It doesn't work either. Having uploaded the ArduinoISP sketch, selecting any board except Mega give me an AVRdude error avrdude: stk500_getsync(): not in sync: resp=0x00 or resp=0x1c or. Selecting Mega, I get several stk500v2_ReceiveMessage(): timeout - before it quits.

Further adding confusion, this YouTube tutorial http://www.youtube.com/watch?v=_ZL-YNOH_jA says I should downlaod WinAVR and use it to generate a hex file. I didn't need to do this when programming my Attiny and several other tutorials don't mention it. Why does he?

Any help would be gratefully received.

Chris

piashaw

I had the same issues too.

However initially I was using the ERW 1.0.4 IDE and it would only allow me to burn a duemilanove bootloader but NOT an UNO bootloader.

I know you already have the duemilanove bootloader installed on the extra chip, but can you try to reupload the same bootloader? For me this was OK, but trying to burn the UNO bootloader didn't.

Once I went back to the original 1.0.4 IDE all worked out fine (with and without the reset cap)

I also had issues trying to program a sketch removing the chip from the UNO and using the Tx and RX pin method, but haven't been able to test if this works with the official 1.0.4 ide. I had the same error message as you. Also some diagrams show a connection to Reset on the breadboard which is needed.

There are quite a few threads on the difference between duemilanove and Uno, but basically a chipped programmed as a duemilanove will work in an UNO.

ChrisXenon

Hello Piashaw and thanks for your interest. From your post I see that IDE version 1.0.5 is out. I was using 1.0.2 and expected it would tell me when an update was available like Processing does. So, I upgraded, but it fixes nothing.

Ask you ask, I tried burning bootloaders:

Setting board = Uno fails:
avrdude: Device signature = 0x1e9514
avrdude: Expected signature for ATMEGA328P is 1E 95 0F

Setting board=Duemilanove w/ ATmega328 fails:
avrdude: Device signature = 0x1e9514
avrdude: Expected signature for ATMEGA328P is 1E 95 0F

Setting board=Arduino mega 2560 or Mega ADK fails:
avrdude: Device signature = 0x1e9514
avrdude: Expected signature for ATMEGA2560 is 1E 98 01

So the device signature is clear anyway.

However, I want to download a C program from the IDE into the chip - I don't want to burn another boot loader.

I can get round this by programming the chip in the Uno board - telling the IDE it's a Due - then physically putting it onto the breadboard to test, then moving it back for updates, etc. but this is tiresome and will snap off some legs sooner or later. I guess I could buy a couple of ZIF sockets and do it that way, but dammit - Arduino's own documentation says it can be done, and numerous tutorials tell you how to do it. I have this hideous notion that I'm doing something incredibly stupid, but I can't see what it might be.

Anyone?

AlxDroidDev

It seems like you have a 328-PU (normal power) and NOT a 328P-PU (low power);

They have different signatures, and that seems to be the root of your problems.

Open avrdude.conf, look for the 328P-PU signature and change it to match the 328-PU.

I don't have the Arduino IDE installed in the computer I am using right now, otherwise I could tell you exactly what line to change. With a 30 seconds search on these forums, you'll be able to do that, 'though.
Some of my projects:
Shield for DS1337+, DS1624 and AT24C1024B (RTC, temp & mem): http://forum.arduino.cc/index.php/topic,126197.0.html
CHDK Camera remote shutter (BT, IR, USB): http://forum.arduino.cc/index.php?topic=295377.0

ChrisXenon

Hello Alx and thanks. I was just reaching the same conclusion. I thought I had 'Ps, but on close inspection, I don't.

I did as you suggest and I got a new error, changing the signature in avrdude,conf. I got a enw error; the NOT SYNCed one I've seen from time to time. This turns out to be a Heisenberg error, however - it disappears if you look at it by holding down SHIFT with upload to see the debug, and it does that reliably. Some minor timing issue, perhaps. So, it's sorted in a sense - thanks.

But I suppose I'm now stuffed if I want to program the Arduino board as the signature will be wrong?
The signature I changed was for the Atmega328p. What I'd really like to do is add a new definition for a "Naked Atmega328 chip" with the infamous signature. I can blather my way around it though, I guess - thanks again.

Chris

Go Up