Arduino Forum

Using Arduino => Avrdude, stk500, Bootloader issues => Topic started by: HamzaY on May 25, 2019, 04:01 am

Title: Invalid Device Signature, was working before
Post by: HamzaY on May 25, 2019, 04:01 am
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.
 
Title: Re: Invalid Device Signature, was working before
Post by: pert on May 25, 2019, 04:15 am
Try connecting a 10 uF capacitor between the reset and ground pins on your Mega.
Title: Re: Invalid Device Signature, was working before
Post by: HamzaY on May 25, 2019, 04:20 am
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.
Title: Invalid Device Signature 0x000000
Post by: HamzaY on May 25, 2019, 04:28 am
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.
 
Title: Re: Invalid Device Signature 0x000000
Post by: dmjlambert on May 25, 2019, 04:40 am
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.   
Title: Re: Invalid Device Signature 0x000000
Post by: HamzaY on May 25, 2019, 04:48 am
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.
Title: Re: Invalid Device Signature 0x000000
Post by: dmjlambert on May 25, 2019, 05:02 am
Are you trying to upload the next sketch using serial via the bootloader, or continuing to use the mega as ISP?
Title: Re: Invalid Device Signature 0x000000
Post by: HamzaY on May 25, 2019, 05:08 am
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.
Title: Re: Invalid Device Signature 0x000000
Post by: HamzaY on May 25, 2019, 05:20 am
bump
Title: Re: Invalid Device Signature 0x000000
Post by: dmjlambert on May 25, 2019, 05:23 am
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.   https://forum.arduino.cc/index.php?topic=519037.0 (https://forum.arduino.cc/index.php?topic=519037.0)
It is not mandatory, but it may increase the audience that will participate in trying to help you troubleshoot.   
Title: Re: Invalid Device Signature 0x000000
Post by: pert on May 25, 2019, 05:30 am
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 (http://forum.arduino.cc/index.php/topic,148850.0.html):
Quote
13. 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 (http://forum.arduino.cc/index.php/topic,148850.0.html).
Title: Re: Invalid Device Signature 0x000000
Post by: HamzaY on May 25, 2019, 06:13 am
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 (http://forum.arduino.cc/index.php/topic,148850.0.html):You already broke the first two rules! Please take the time to read the "How to use this forum" post (http://forum.arduino.cc/index.php/topic,148850.0.html).
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.



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.   https://forum.arduino.cc/index.php?topic=519037.0 (https://forum.arduino.cc/index.php?topic=519037.0)
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.
(https://forum.arduino.cc/index.php?action=dlattach;topic=617823.0;attach=309750)

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.
(https://forum.arduino.cc/index.php?action=dlattach;topic=617823.0;attach=309753)

This is mcu on my pcb
(https://forum.arduino.cc/index.php?action=dlattach;topic=617823.0;attach=309755)

Breadboard
(https://forum.arduino.cc/index.php?action=dlattach;topic=617823.0;attach=309748)

Arduino
(https://forum.arduino.cc/index.php?action=dlattach;topic=617823.0;attach=309746)

Title: Re: Invalid Device Signature 0x000000
Post by: dmjlambert on May 25, 2019, 06:32 am
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.   
Title: Re: Invalid Device Signature 0x000000
Post by: dmjlambert on May 25, 2019, 06:45 am
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. 
Title: Re: Invalid Device Signature 0x000000
Post by: dmjlambert on May 25, 2019, 06:50 am
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.   
Title: Re: Invalid Device Signature 0x000000
Post by: HamzaY on May 25, 2019, 06:57 am
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.
(https://forum.arduino.cc/index.php?action=dlattach;topic=617823.0;attach=309759)

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.

Title: Re: Invalid Device Signature 0x000000
Post by: dmjlambert on May 25, 2019, 07:21 am
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.



Title: Re: Invalid Device Signature 0x000000
Post by: HamzaY on May 25, 2019, 07:51 am
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.
Title: Re: Invalid Device Signature, was working before
Post by: Coding Badly on May 25, 2019, 09:22 am

Threads merged.

Title: Re: Invalid Device Signature, was working before
Post by: HamzaY on May 27, 2019, 11:25 pm
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.