[SOLVED] ATMEGA328P Weird programming issues

Hi,

I have a ATMega328P in a setup very similar to the one described on here: https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard

I can program the microcontroller just fine with USBasp: I can burn the Arduino bootloader and I can flash programs by using an "Upload Using Programmer" option or avrdude, both of which work fine.

However, I cannot flash via serial. Log:

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0
An error occurred while uploading the sketch

All 10 attempts occur within 2 seconds or so.

I suspected a dead serial transceiver on the microcontroller, but it seems to work fine; if I upload a program which listens on serial and then transmits the data back, I get the expected response.

The FTDI232 board I'm using works fine, tested with Arduino Pro Mini.

I have tried both external clock (12MHz crystal + 2*22pF) and internal clock and the issue is exactly the same.

Does anybody have any ideas as to why this problem occurs?
Thanks

(deleted)

No, that's why I also tried using the internal oscillator.

(deleted)

(deleted)

I did download the board files from said article (breadboard-1-6-x.zip) and certainly flashed the correct bootloader to the microcontroller "ATMega328 on a breadboard (8MHz internal oscillator)".
In fact, I got a sketch running correctly, blinking LEDs and sending/receiving data over Serial.

The only thing not working is the upload via Serial.

I did not calibrate the chip as it should not be required for such a simple setup - and there is no mention of it in the article.

I did this previously (also ATMega328, but from a different supplier) and everything worked, including the serial upload.

Wow! To be an "official" arduino tutorial, installing the breadboard-1-6-x.zip is a poor option. No configuration options, "hard" to install, and no documentation of the code.

Do your self a favor and install MiniCore instead. It it's well documented, got a 12 MHz option, up to date and is really easy to install.

If this doesn't work, it's a HW problem :wink:

(deleted)

Yes here it is:


The 104 capacitor is there and is good - measured 93.7nF. This is a circuit with the crystal removed.

I have built the exact same thing on a breadboard with a different chip and it works completely fine, so I will swap the ICs and see what it does.

I changed the ATMega and now it finally works fine. The chip was from eBay for a rather low price.
Thank you all for your help.