Trouble bootloading Atmega328p-au, are my capacitors messing with it?

I've been trying to flash a bootloader to an atmega328p-au. I use an Arduino nano as an ISP and have been double/triple checking my wiring because I'm getting the following error:

avrdude: Device signature = 0xffffff (probably .avr8x_mega)
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

this shows up with both the Arduino IDE bootloader and the MiniCore bootloader flasher module. Sometimes it will also be 0x00000000 or 0xffff0000

I have a sneaking suspicion it's because of my crystal oscillator circuit which is admittedly wrong as I have 100nf instead of 22pf capacitors , which you can see below:

That said, I encountered this thread
Thread discussion on Atmega328p-AU (touches on oscillators) where someone said:

will occur if you're using ArduinoISP to flash a target Arduino and the target is not physically connected. So it really is an "all bets are off" message that doesn't pinpoint any particular cause. To troubleshoot, checking wiring if a good first step.

Do not, on the other hand, concern yourself with the external clock signal. In contrast to some guides, the ATmega328P at least comes factory configured to use an internal RC oscillator, so even a correctly connected crystal or resonator on the XTAL pins will not show any activity until the first successful flash.

so now I'm wondering how big of an impact these caps actually have. Any help or feedback?

The capacitors across the crystal are orders of magnitude too large. I can't imagine it oscillates.

22pF is a common value, but consult the crystal data sheet for the most appropriate load capacitance (which takes into account stray PCB capacitance).

If you have a genuine, brand new ATmega chip, then the fuses are set for 8 MHz internal RC oscillator, divided down by 8 (CKDIV8), for F_CPU = 1 MHz. The ISP programmer clock frequency must be less than 250 kHz.

1 Like

Thanks for the answer, I have some more questions (which may be dumb but I will shoot anyway).

In light of my capacitor mishap, I was planning to try to salvage my boards by either retrieving a capacitor from a donor arduino nano but I just found that they don't have any xtal capacitors installed which I confirmed here .
How is this possible and can I perhaps do the same? (I'm aware that the minimal setup to flash a bootloader according to MiniCore git needs a crystal and 22pf capacitors)

on the ISP topic, since you mentioned that the ISP programmer needs to be clocked at 250 kHz , can I still accomplish this with the Arduino ISP? and if so can you point me to any references I can read?

You can use a 16 MHz resonator, which typically has capacitors built in. There are a few crystal options that also have capacitors. Both come in three terminal packages, with a ground connection.

Or, just buy some 22 pF capacitors and get on with your project. Finally, if you can live with 8 MHz, just leave the RC oscillator fuses as they are, making sure that the CKDIV8 fuse is off.

The Arduino ISP should have a clock speed setting, and it must be set to less than 1/4 of the CPU clock frequency. The ATmega data sheet covers all this in the memory programming section, which you should spend some time studying.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.