Hello everyone, I know that there are a lot of similar posts but I couldn't find an answer..
I designed my own custom pcb as Arduino-Uno equivalent and I'm trying to program it.
First, I tried to burn the bootloader to ATMEga328P using an arduino mega 2560 as programmer, as suggested in the documentation but I get either "Invalid device signature error" or "Expected signature for ATmega328P is 1E 95 0F" avrude error. I managed to burn the bootloader using this code and everything completes successfully (including verification).
After that, I programmed ATMEGA16U2 using Flip 3.4.7 software to upload the hex file found here and finally the board is recognized as Arduino Uno.
It is displayed correctly under device manager, in Arduino IDE (v.1.8.19) it is also shown correctly in the appropriate port and I can also get back the board info (BN, VID, PID, SN).
However, when I try to upload a sketch through the IDE I get the following error:
An error occurred while uploading the sketch avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xc2
I've checked polarity of tx/rx lines, DTR signal is connected correctly and I can't figure out what might be going wrong. Any help would be much appreciated.
One more update from my side, if it helps.
I used again code from Nick Gammon's forum to readback the contents of the chip that I want to program and I got the response below, which I believe looks normal.
One thing that I noticed, is that the chip type is ATMega328 and not ATMega328P, could this create a problem? The code for ATMega16U2 targeting Arduino Uno is expecting ATMega328P, is it possible that they have different signatures and something is going wrong there?
Thanks again.
Atmega chip detector.
Written by Nick Gammon.
Version 1.20
Compiled on Jun 7 2022 at 20:24:30 with Arduino IDE 10609.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x14
Processor = ATmega328
Flash memory size = 32768 bytes.
LFuse = 0xFF
HFuse = 0xDE
EFuse = 0xFD
Lock byte = 0xEF
Clock calibration = 0x46
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 512 bytes starting at 7E00
You have a 1k resistor on the 328 RESET signal, and it should probably be 10k.
(some Nanos have 1k pullups, but they don't have the 1k pulldown on DTR. (And they're wrong.))
The 328 vs 328p may be a thing as well, but you would get an "invalid signature" error rather than "not repsonding." (maybe not, depending on whether the bootloader is the lying version or not.)
Hi westfw, thanks for your answer. Actually I have already changed the resistor and the 1uF cap (which is now 100nF) on the DTR signal.
The 328 vs 328P issue I think that explains at least why I couldn't burn the bootloader with the standard way through Arduino IDE and I was getting the invalid signature error.