Programming blank atmega 328p smd

Hi there, I'm new to the forum but I've been using Arduino boards for a long time now, and I recently decided to start going standalone and using the processors alone without the entire board.

I received the other day some boards I ordered mounting a smt atmega 328p and I'm completely unable to burn the bootloader or the code, after days of googling and looking into this forum I haven't been able to reach a solution. This is what I've been doing, without success:

1- write the Arduino as ISP program into my Arduino Uno board (I tried both uncommenting the "use old wiring" setting and keep it commented, with no change)
2- Connect the UNO ICSP header to the ICSP on my custom board
3- select Burn bootloader from the arduino IDE / Upload the script using programmer

This is the verbose log after trying this:

         Using Port                    : COM3
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

An error occurred while uploading the sketch
Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x00ffff
avrdude: Expected signature for ATmega328P is 1E 95 0F
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

The device signature sometimes change when I try It again, I've seen 0x000000, 0x00ff00 and a few others.

This is what the relevant part of my circuit looks like,

My main suspect is that Oscillator : Off so if it helps this is the model my board is mounting Yangxing Tech|Yangxing Tech X322516MLB4SI|SMD Crystal Resonators|LCSC

Thank you for any help, I've been all week trying stuff and I'm still at square one, sorry if the post ended up being too long, and have a nice day

A couple of things:

A virgin 328p from the factory in configured to run from its internal oscillator. Off the top of my head I can't recall if the DIV 8 fuse is set as well.

I don't see any decoupling capacitors in your schematic. There should be some 100n ones in there on the power pins etc.

EDIT: if you search for something like minimum Arduino breadboard, you will see some examples with the minimum number of components required.

I don’t see any decoupling capacitors in your schematic. There should be some 100n ones in there on the power pins etc.

Sorry, I forgot to include them but there are three decoupling caps in the circuit, 100nF, 10u, 100u

Are you able to burn the bootloader to another Arduino? Just try to isolate where the problem is.

1- write the Arduino as ISP program into my Arduino Uno board (I tried both uncommenting the “use old wiring” setting and keep it commented, with no change)
2- Connect the UNO ICSP header to the ICSP on my custom board
3- select Burn bootloader from the arduino IDE / Upload the script using programmer

I am not sure which IDE or Arduino as ISP you are using.
I searched for “use old wiring” in the Arduino as ISP in the examples for IDE version 1.8.13 and could not find it.

You mention connecting “UNO ICSP header to the ICSP on my custom board”. When using the Arduino as ISP, in the IDE samples, you need to connect pin 10 on the UNO to the reset on your board’s ICSP reset - the reset pin on the UNO ICSP is not used during upload.

In the IDE under Tools, you need to select Arduino as ISP as programmer and just click “Burn Bootloader”. (I do not understand where “Upload the script using programmer” comes in.

Try just uploading the “Blink” example (use Upload). It never failed for me using the above (except when I have a wiring problem) .

Willem.

Willem43:
You mention connecting "UNO ICSP header to the ICSP on my custom board". When using the Arduino as ISP, in the IDE samples, you need to connect pin 10 on the UNO to the reset on your board's ICSP reset - the reset pin on the UNO ICSP is not used during upload.

That was it!!! For some reason I assumed I had to connect ALL the ICSP header to the new ICSP header, but I guess the chip was resetting because of this
Thank you so much!

Great.

For some reason I assumed I had to connect ALL the ICSP header to the new ICSP header

When using a programmer that would be the case. The reset pin on a programmer is wired to control the reset for upload (the same as pin10 on he UNO). The ICSP on the UNO is wired to program the 328P on it, hence the use of pin10, when used as an ISP programmer, to control the reset on the device being programmed.

Glad I could help.

Willem.