Trying to program custom atmega320pb board with UNO and/or NANO

Hello,
I am trying to program my custom atmega328pb board with both UNO and NANO as ISP programmers. I have uploaded ArduinoISP sketch to UNO (and later NANO) and then connected pins D13, 12, 11 and 10 (as well as 5V and gnd) to custom PCB ISCP header. Then I changed programmer to Arduino as ISP and tried burning bootloader but it gives me an error:

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avrdude -CC:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM9 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m 



avrdude: Version 6.3-20190619

         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         Copyright (c) 2007-2014 Joerg Wunsch



         System wide configuration file is "C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf"



         Using Port                    : COM9

         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



Reading | ################################################## | 100% 0.02s



avrdude: Device signature = 0x000000 (retrying)



Reading | ################################################## | 100% 0.02s



avrdude: Device signature = 0x000000 (retrying)



Error while burning bootloader.

Reading | ################################################## | 100% 0.02s



avrdude: Device signature = 0x000000

avrdude: Yikes!  Invalid device signature.

         Double check connections and try again, or use -F to override

         this check.





avrdude done.  Thank you.





This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I have checked connections several times but not sure why it gives an error.
Any ideas what is going on?

atnega328p is not the same as atmega328pb. You should select a correct mcu to upload.

And then -

Signature with all zeros means connection problems. twice check your wirings.
Please draw the connection diagram and show in the forum.

2 Likes

BTW
if you are using a DIY board with an external resonator for clocking, it is very likely that your controller simply does not start. Try to apply an external clock signal with a frequency of 1-8 MHz to pin xtal1 and flash again

As for custom board, basically I tried simulating UNO board so I have used external 16Mhz oscillator connected in parallel between xtal2 and xtal1 pins.
As for the board when trying to burn bootloader I selected UNO, should've I selected another one? So I need to try apply external clock signal somehow because it wont work otherwise? As for connection I triple checked them, on custom pcb I even checked if ISCP pins header is properly connected to atmega328pb pins and it is.

Indeed
You should selected exact atmega328pb.
The signatures of the chips are different, the avrdude program will not be able to flash the bootloader if you chose the usual atmega328p and try to flash the atmega328pb.

In my boards I do not see atmega328pb as an option, it is only regular boards.
Should I maybe install or add something to be able to see that option?

There are some packages, supports the atmega328 "PB" variant. For example:

You also can try to call avrdude directly from command line.

I have switched to NANO as programmer, installed boards you mentioned and selected atmega328pb Xplained mini, now I get this error which is different than one on UNO:

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Atmel atmega328pb Xplained mini"

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avrdude -CC:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM9 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFC:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xE0:m 



avrdude: Version 6.3-20190619

         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         Copyright (c) 2007-2014 Joerg Wunsch



         System wide configuration file is "C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf"



         Using Port                    : COM9

         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



Reading | ################################################## | 100% 0.02s



avrdude: Device signature = 0xffffff (probably .avr8x_mega) (retrying)



Reading | ################################################## | 100% 0.02s



avrdude: Device signature = 0xffffff (probably .avr8x_mega) (retrying)



Error while burning bootloader.

Reading | ################################################## | 100% 0.02s



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.





avrdude done.  Thank you.





This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

No, it is the same error. Signatures with zeros or 0xffffff has the same meaning - "no responce from the chip".

It is still a connection problem or chip doesn't start.

Im 99.99% sure connection isnt an issue so I guess chip doesent start is the issue. Like I said Ive been copying UNO with custom PCB and I have connected external 16Mhz oscillator in parallel between xtal2 and xtal1 pins with all other components that go with it (capacitors and if I remember correctly resistor as well). How can I start the chip if it doesent start by itself at this point? You mentioned bringing external signal to xtal1 pin somehow?

Nano Atmega328pb
D13 -> SCK(pb5)
D12 -> MISO(pb4)
D11 -> MOSI(pb3)
D10 -> RST(pc6)
5V -> VCC(
GND -> GND(

Use a custom version of the ArduinoISP which adds an 8 MHZ 'crystal' output on pin #9 :

So basically I upload this sketch to programmer and then connect d9 to xtal1 pin of atmega328pb and then burn bootloader? I will try that now.

Hi,
Can you post a schematic of your project?

Can you post some EXPORTED jpg images of your PCB pattern?

Did you breadboard this project before going to PCB?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

I have uploaded new ArduinoISP sketch from the link provided and this is what happens now:

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Atmel atmega328pb Xplained mini"

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avrdude -CC:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM9 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFC:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xE0:m 



avrdude: Version 6.3-20190619

         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         Copyright (c) 2007-2014 Joerg Wunsch



         System wide configuration file is "C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf"



         Using Port                    : COM9

         Using Programmer              : stk500v1

         Overriding Baud Rate          : 19200

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x03

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x03

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x03

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x03

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x03

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x03

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x03

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x03

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x03



avrdude done.  Thank you.



Error while burning bootloader.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

As for the schematics I will upload shortly. I have tested functionality of the parts I want to control with UNO board and this custom pcb should simulate UNO board in sense it has necessary parts to work.

I used this sketch and it worked for me. Honesty, I did not download it from the github, but found it on the network.
If you do not find a solution before, I can post my version for you. But it will be in the evening, after 8pm (GMT +3) .

Yeah you can do it as I can try with your sketch tomorrow then.
Here is pcb schematic:

You CAN NOT have MOSI connected to buzzer.
Remone R3 and try again

1 Like

Buzzer is not on pcb while I am uploading the code so there is an open line on the connectors where buzzer goes. But after I successfully upload the code isn't it possible to use pin as buzzer control? On UNO you can still use d11 even though it is mosi pin to connect external stuff on it?

If you use a SPI bus in the code - you can't use D11 and other spi pins for any purposes other than spi bus.
In other cases, this is the same pin as any other

I am only using it to program the pcb, after that I dont use it anymore in the code. And it should not cause any problems while programming since the buzzer is not connected on the board currently so there is an open line after the R3 resistor, right?