Invalid Device Signature, was working before

Hi i am trying to program atmega328p-au using arduino mega as an isp. I was able to burn boot loader and upload a blink sketch. Which was working.

Later i tried to upload other sketches and i would get invalid signature error with signature being some random value. But after some tries the sketch would upload.

After that signature would always verify and but i would get byte mismatch on location 0x0000.

Now i am getting Invalid Device signature error with signature being 0x000000 always.

My wiring:(it's correct as i did upload blink sketch and bootloader using this)

328p ------------ Mega
15(MISO) -------->51
16(MOSI) -------->50
17 (SCK) -------->52
29(Reset)-------->10------->10k ohm ------->5v

328p is powered using external supply.
All grounds are common.

Help will be really appreciated.

Try connecting a 10 uF capacitor between the reset and ground pins on your Mega.

pert:
Try connecting a 10 uF capacitor between the reset and ground pins on your Mega.

I forgot to mention in the post but the capacitor is already connected between reset and ground on mega. Also a capacitor between 5v and ground of supply is also connected already. Also capacitor does not seems to be issue as i am getting no signature at all. Just blank 0x000000 and it was working before.

Hi i am trying to program atmega328p-au using arduino mega as an isp. I was able to burn boot loader and upload a blink sketch. Which was working.

Later i tried to upload other sketches and i would get invalid signature error with signature being some random value. But after some tries the sketch would upload.

After that signature would always verify and but i would get byte mismatch on location 0x0000.

Now i am getting Invalid Device signature error with signature being 0x000000 always.

My wiring:(it's correct as i did upload blink sketch and bootloader using this)

328p ------------ Mega
15(MISO) -------->51
16(MOSI) -------->50
17 (SCK) -------->52
29(Reset)-------->10------->10k ohm ------->5v

328p is powered using external supply.
All grounds are common.
cap between 5v and ground.
cap between reset and ground of Mega

Help will be really appreciated.

Perhaps during bootloading you set fuses to values that require an external crystal to be attached to the ATmega328p, but you don't have a crystal attached.

dmjlambert:
Perhaps during bootloading you set fuses to values that require an external crystal to be attached to the ATmega328p, but you don't have a crystal attached.

I am using MiniCore atmega328p board library to upload boot loader. I did select 16 MHz external crystal before uploading bootloader.

But the external crystal is attached and working.
I know because of these facts:
1- I checked crystal using oscilloscope before burning boot loader it was working.
2- After uploading bootloader i also successfully upload blink sketch.
3- Blink sketch was working.

Are you trying to upload the next sketch using serial via the bootloader, or continuing to use the mega as ISP?

dmjlambert:
Are you trying to upload the next sketch using serial via the bootloader, or continuing to use the mega as ISP?

While using mega as isp i am trying to upload through 'upload using a programmer' option.

Also sorry for late reply i can post 1 reply every 5 min.

bump

OK I just wanted to make sure you weren't trying to use serial and the bootloader to upload, such as through an FTDI adapter or something like that. It would add an additional thing to troubleshoot. Plus whenever you upload a sketch such as the blink sketch via programmer, it removes the bootloader from the ATmega328p. That is OK, because when you're uploading a sketch with a programmer, you don't need the bootloader anyway. It is still good you did the burn bootloader step, because that is when your fuses are set.

Anyway, it seems to me you may have an intermittent problem, which is annoying. Many things could be causing that. Bad wiring, something wrong with the soldering, power supply, circuit design, etc. It is probably time to show us a full schematic of your circuit or board, and perhaps a good clear photo of the board.

Robin2 made this guide that you may find useful, to include displaying the picture in your post, instead of just plain upload that shows a link. Simple guide for inserting images in a post - Website and Forum - Arduino Forum
It is not mandatory, but it may increase the audience that will participate in trying to help you troubleshoot.

HamzaY:
bump

Really? A bump after 12 minutes? That's not how things go here. You'll only make it less likely for you to get help with that sort of behavior.

From the "How to use this forum" post:

  1. Forum etiquette

Once you have made your post, here are a few other guidelines:

Don't cross-post!

We know you are anxious to get an answer to your problem, but re-posting the same question to multiple parts of the forum causes duplicate effort, and divides the focus on your problem. You'll get a better answer if everyone can discuss it in one place. Cross-posting is very annoying; the moderators will delete your extra posts, and you will get a warning. Save all the hassle, and just post the question once. It will be noticed.

If you aren't sure what section to post in (Programming Questions, Electronics, etc.) make a guess. Don't cross post "just in case".

Don't bump!

Don't bump your thread after an hour. Because of the different time-zones the person who knows the answer may be asleep, or away for the day. Maybe after a couple of days.

If your question didn't get an answer, honestly review it to see if you posted enough information to help people answer you. Did you even ask a question?

You already broke the first two rules! Please take the time to read the "How to use this forum" post.

pert:
Really? A bump after 12 minutes? That's not how things go here. You'll only make it less likely for you to get help with that sort of behavior.

From the "How to use this forum" post:You already broke the first two rules! Please take the time to read the "How to use this forum" post.

After my first post i realized that i had posted in wrong section and someone replied to that post so i did not wanted that post to be deleted in case he chose to reply again. I understand the rule now and will delete the other post.
Also i will also keep rule about bump in mind.
Edit: this is my first time posting on arduino forum i think only moderator can delete the post correct me if i am wrong.

dmjlambert:
OK I just wanted to make sure you weren't trying to use serial and the bootloader to upload, such as through an FTDI adapter or something like that. It would add an additional thing to troubleshoot. Plus whenever you upload a sketch such as the blink sketch via programmer, it removes the bootloader from the ATmega328p. That is OK, because when you're uploading a sketch with a programmer, you don't need the bootloader anyway. It is still good you did the burn bootloader step, because that is when your fuses are set.

Anyway, it seems to me you may have an intermittent problem, which is annoying. Many things could be causing that. Bad wiring, something wrong with the soldering, power supply, circuit design, etc. It is probably time to show us a full schematic of your circuit or board, and perhaps a good clear photo of the board.

Robin2 made this guide that you may find useful, to include displaying the picture in your post, instead of just plain upload that shows a link. Simple guide for inserting images in a post - Website and Forum - Arduino Forum
It is not mandatory, but it may increase the audience that will participate in trying to help you troubleshoot.

This is the circuit. Black lines are used to represent a connection or a wire.

This pcb was originally made for 328pb-au instead of 328p-au that i am using now. I modified the circuit according to 328p-au pinout.

Picture of overall system little messy but wiring is correct checked many times.

This is mcu on my pcb

Breadboard

Arduino

I suggest using the method Robin2 made in that article I mentioned, to include displaying the picture in your post, instead of just plain upload that shows a link, or worse yet text that looks like a link that somebody trying to help you would have to copy and paste into a separate browser window. I suggest make your posts easier to follow for those who may want to chime in. By the way, I did notice you making a post offering a tip on another post, kudos and it is great to see you're able to contribute.

Good improvement on the posts, thanks. It would be good to improve the schematic a bit, so we understand the corrections made by the black lines.

Do you have both VCC pins and the AVCC pin connected to the power supply, and all 3 grounds connected to ground? I can't tell from the pictures.
Do you have 0.1uF decoupling capacitors connected close to the VCC and ground pins? I think other folks will point out those are important to include and I don't see them in your schematic.

dmjlambert:
Good improvement on the posts, thanks. It would be good to improve the schematic a bit, so we understand the corrections made by the black lines.

Two ic grounds are connected to ground.

Black lines are used to represent a connection or a wire. VCC and AVCC both are connected to 5v.

Also setup is a little messy so if you need anymore assist understanding feel free to ask.

I recommend working on cleaning up the schematic to make it very clear, and make corrections so it represents what you actually have on your completed board.

Are you using atmega328p-au or atmega328pb-au IC on your board? They are different, and I am concerned that you mentioned atmega328p above but schematic says atmega328pb.

Are the atmega328p pins 16 and 23 connected together and going to MISO?
And are pins 29 and 1 connected together and going to your reset pullup?
There should be 2 VCC, 1 AVCC, and 3 grounds, but the schematic does not show all those.
I'm afraid you need decoupling capacitors, that may be the root of the problem, but I don't know.

dmjlambert:
I recommend working on cleaning up the schematic to make it very clear, and make corrections so it represents what you actually have on your completed board.

Are you using atmega328p-au or atmega328pb-au IC on your board? They are different, and I am concerned that you mentioned atmega328p above but schematic says atmega328pb.

Are the atmega328p pins 16 and 23 connected together and going to MISO?
And are pins 29 and 1 connected together and going to your reset pullup?
There should be 2 VCC, 1 AVCC, and 3 grounds, but the schematic does not show all those.
I'm afraid you need decoupling capacitors, that may be the root of the problem, but I don't know.

i am using atmega328p-au. I understand both are different and that is why i had made changes to pcb as shown in schematics. Rest of pinout is same. And yes pin 29 to 1, 16 to 23 and 17 to 24 is connected to account for different variant of ic. Also decoupling capacitor is also connected between gnd and 5v. (i think wiring is not the problem as if it was it wouldnt have worked the first time)

I also been searching other posts for possible solution what i understand is during unsuccessful uploads,fuses were somehow changed resulting in bricking of 328p.

Also is there any way to over ride the signature verification, i know it wont upload but wanna do it just to understand the problem better.

Also thanks for your help too, i know you are trying your best and i really appreciate it.

Threads merged.

Solved!!!
The issue was that after few time successfully uploading code using 'upload using programmer' for some reason the atmega 328p got bricked (happened twice with two different atmega 328p). So solution was that to change atmega 328p ic and burn boot loader after that instead of using isp programming to upload your code use FTDI programmer .

Thanks Everybody for help.