ATMEGA328PB-AN bootloader burning

Hi

For several years I've been using an Arduino Uno as an ISP to burn bootloaders and upload sketches to different Arduino compatible chips through SPI communication. Common to all my past projects is that I haven't been using external clocks (crystals) for the target chips.

I've recently started work on a project where the target chip is a ATMEGA328PB-AN (SMD) clocked with an external 16MHz crystal. The chip was bought from Mouser. I'm now having trouble burning the bootloader onto the chip.

My method:

  1. I soldered up the Atmega, crystal, 22pF crystal caps and 100nF bypass caps as well as a header socket for communication with the Arduino on my custom target PCB. No other components are present on the PCB at this time. All connections have been tested with a DMM.

  2. I connect my programmer Arduino Uno with a custom level shifter PCB shield to the target PCB. The Arduino and custom shield is working correctly when used together with my other Arduino compatible projects. The Shield connects pins D10,11,12,13 of the programmer Arduino Uno to the RESET, SCK, MISO and MOSI pins of the target Atmega via level shifters. The target Atmega is powered by the 3.3v output of the programmer Arduino Uno board. Additionally the RESET pin of the programmer Arduino Uno is connected to a 10uF cap to ground.

  3. In Arduino IDE I select "Arduino/Genuino Uno" and "Arduino as ISP" and then select "Burn Bootloader"

  4. I receive the following error message:

Arduino:1.8.5 (Windows 10), Card"Arduino/Genuino Uno"
avrdude: Expected signature for ATmega328P is 1E 95 0F
Double check chip, or use -F to override this check.
An error occurred during bootloader burning.

If i attempt to upload a blank template sketch to the target Atmega I receive the following error:

Arduino:1.8.5 (Windows 10), Card"Arduino/Genuino Uno"

Archiving built core (caching) in: C:\Users\xxx\AppData\Local\Temp\arduino_cache_334018\core\core_arduino_avr_uno_0c812875ac70eb4a9b385d8fb077f54c.a
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xfb
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0
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=0xe0
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0

I've also tried the "ATMEGA328-PB testing" (github link) without success, producing the following error message:

Arduino: 1.8.5 (Windows 10), Board: "ATmega328PB Crystal Clock, 16 MHz"

***failed;
avrdude.exe: WARNING: invalid value for unused bits in fuse "efuse", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xf5 instead of 0xfd (double check with your datasheet first).
avrdude.exe: Expected signature for ATmega328PB is 1E 95 16
Double check chip, or use -F to override this check.
Error while burning bootloader.

Also tried the minicore boards which gave the following error:

Arduino: 1.8.5 (Windows 10), Board: "ATmega328, Yes (UART0), 328PB, BOD 2.7V, LTO disabled, External 16 MHz"

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Users\knuto\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.5/avrdude.conf"

Using Port : COM3
Using Programmer : stk500v1
Overriding Baud Rate : 19200
AVR Part : ATmega328PB
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
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
efuse 0 0 0 0 no 1 0 0 4500 4500 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 (retrying)

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

avrdude: Device signature = 0xffffff (retrying)

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

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

avrdude done. Thank you.

Error while burning bootloader.

I've googled the issue, but have been unable to find an explanation for why this is happening. I've checked all connections which leads me to believe that the issue is with my method itself rather than the execution of said method.

Hope someone have suggestions for what to do different.

Append: Would I have an easier time if I went with a ATMEGA328P instead of the PB? I kinda ordered the PB-type by mistake. Should I expect my original method to work if I use a P in place of the PB?

  1. RESET should be tied to VCC via resistor, 10kOhm usually. Does it?
  2. 3.3V is bit out of specification for 16MHz.
  3. [avrdude: Expected signature for ATmega328P is 1E 95 0F] PB has different signature 1E9516. You need edit .conf.

Minicore result looks like shortage on some wire. It can be because response is all FF.

Thanks! I’ll try again next week with a ATMEGA328P and a 8MHz crystal using the first method described in this thread:

Follow-up on the progress:

I've changed the chip to a ATMEGA328P (TQFP) and the crystal to a 8MHz type. Still using my Arduino UNO as a ISP through SPI communication I'm able to burn the "Pro Mini Atmega328P 3.3V 8MHz" bootloader onto the chip successfully.

However I'm not able to upload any code to the chip. I receive the following error:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x50
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x1c
Problem uploading to board.

Very confused as to what's going on here. I'm using the same communication method (SPI) as for the bootloader burning and I've tested that my Arduino Uno works for uploading programs to other chips.

Any suggestions?

Maybe serial speed. What serial speed the bootloader is for and which speed is used for uploading? Please, post the whole log include the command used for upload, otherwise it is like guessing from the crystal ball.

Just to clarify, are you attempting to upload the code using the UNO as an ISP programmer, using Sketch > Upload Using Programmer in the IDE?

Are you able to burn the bootloader a 2nd time?

In reference to your original question concerning using an atmega328PB, have you tried the bootloader from MCUdude's MiniCore, that has a variant for that particular chip. I see you already tried this.

Had to change the language of my IDE in order to get the “Verbous option” for some reason (Norwegian user).

Below I’ve attached the compilation message from an unsuccessful regular upload (ctrl + U) and a successful shift-upload (ctrl + shift+ U). I’m very it worked with the shift-upload, but don’t understand why…

To answer david_2018:
I’m able to burn the bootloader multiple times and I’m using an Arduino Uno running the ArduinoISP sketch as an ISP through SPI communication.

I’m very thankful for the invaluable support this forum provides. Is there any way someone less knowledgeable like myself can support the forum?

Unsuccessful regular upload:

Arduino: 1.8.5 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328P (3.3V, 8 MHz)"

Build options changed, rebuilding all
Archiving built core (caching) in: C:\Users\knuto\AppData\Local\Temp\arduino_cache_409210\core\core_arduino_avr_pro_cpu_8MHzatmega328_0c812875ac70eb4a9b385d8fb077f54c.a
Sketch uses 940 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM3 -b57600 -D -Uflash:w:C:\Users\knuto\AppData\Local\Temp\arduino_build_852722/testarduino8Mhz.ino.hex:i 

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xd6
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1c
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x1c

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

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

Successful shift-upload:

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         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

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

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Users\knuto\AppData\Local\Temp\arduino_build_852722/testarduino8Mhz.ino.hex"
avrdude: writing flash (940 bytes):

Writing | ################################################## | 100% 1.13s

avrdude: 940 bytes of flash written
avrdude: verifying flash memory against C:\Users\knuto\AppData\Local\Temp\arduino_build_852722/testarduino8Mhz.ino.hex:
avrdude: load data flash data from input file C:\Users\knuto\AppData\Local\Temp\arduino_build_852722/testarduino8Mhz.ino.hex:
avrdude: input file C:\Users\knuto\AppData\Local\Temp\arduino_build_852722/testarduino8Mhz.ino.hex contains 940 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.64s

avrdude: verifying ...
avrdude: 940 bytes of flash verified

avrdude done.  Thank you.

Ctrl+shift+U is upload using programmer not via serial port and bootloader. Are you using Arduino as ISP?

I'm very thankful for the invaluable support this forum provides. Is there any way someone less knowledgeable like myself can support the forum?

You are welcome! Forum is for free. There are volunteers like me which are prepared to help to someone like you.
Your contribution is in your topics and your questions. Other people are reading.
And of course you can donate -> download site.

Personally, my motivation is not just interest about electronics. I am glad that interest is spreading. At the same time people's education grows up. I know, nowadays you can buy everything you need, ready to go; but this is not as if you accomplish your goals by yourself. You can pay for stuff with credit card but good feeling is priceless.

Budvar10:
Ctrl+shift+U is upload using programmer not via serial port and bootloader. Are you using Arduino as ISP?

Yes I'm using Arduino as ISP (Arduino Uno with custom level shifter shield).

Isn't it odd that one works and the other doesn't?

Is it problematic or does it give me a different result when I shift-upload?

The reason this is bothering me is that I want to feel safe that this will work for several PCBs as I intend to making a few of them.

Budvar10:
Your contribution is in your topics and your questions. Other people are reading.
And of course you can donate -> download site.
priceless.

Thanks and thank you for your volunteering! I'll look about placing a donation! :slight_smile:

Just want to make sure that you are aware that uploading code via ISP programmer erases the bootloader, with your previous experience I've been assuming you would not make that mistake.

Can you post a schematic and board layout for your custom board? I'm starting to suspect this may be a hardware problem.

I've recently started work on a project where the target chip is a ATMEGA328PB-AN (SMD) clocked with an external 16MHz crystal.

I've changed the chip to a ATMEGA328P (TQFP) and the crystal to a 8MHz type.

If you just put a 328P onto a board designed for the ATmega328PB, it's not surprising that it doesn't work. The chips are not quite pin-compatible (in particular, the 328P wants power on pins that are IO pins on the PB.)

david_2018:
Just want to make sure that you are aware that uploading code via ISP programmer erases the bootloader, with your previous experience I’ve been assuming you would not make that mistake.

Can you post a schematic and board layout for your custom board? I’m starting to suspect this may be a hardware problem.

I was not aware of that. So what you are saying is that when I upload code with an Arduino Uno as ISP it will rewrite the bootloader of the target MCU with the current settings set up in the Arduino IDE before uploading the program itself?

I’ve attached a schematic of what I currently have wired up on the PCB.

westfw:
If you just put a 328P onto a board designed for the ATmega328PB, it’s not surprising that it doesn’t work. The chips are not quite pin-compatible (in particular, the 328P wants power on pins that are IO pins on the PB.)

Actually I designed the PCB for the ATMEGA328P which might help explain why I couldn’t get it working the the “PB”. I bought the “PB” chips believing it was the same base chip. After realizing the mistake I bought some “P” chips. I’m able to upload code using the [CTRL + SHIFT + U] command.

Budvar10:
Ctrl+shift+U is upload using programmer not via serial port and bootloader.

Sorry I still don’t quite understand the difference here. I will look for further documentation on this distinction.

Arduino_forum_atmega328P.pdf (42.3 KB)