Atmega328pb - au, bootloader issue

Hi, I'm truing to get bootloader on some atmega328pb chips.
so far i've got no luck, I keep getting this error:

avrdude: Version 7.2-arduino.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\Users\simon\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1\avrdude.conf

         Using Port                    : COM10
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328PB
         Chip Erase delay              : 10500 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                 65    20     4    0 no       1024    4      0  3600  3600 0x00 0x00
           flash                  65    10   128    0 yes     32768  128    256  4500  4500 0x00 0x00
           lfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           hfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           efuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           lock                    0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
           calibration             0     0     0    0 no          1    1      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
avrdude: device signature = 0x000000 (retrying)
avrdude: device signature = 0x000000 (retrying)
avrdude: device signature = 0x000000
avrdude main() error: Yikes!  Invalid device signature.
avrdude main() error: expected signature for ATmega328PB is 1E 95 16
        Double check connections and try again, or use -F to override
        this check.


avrdude done.  Thank you.

Failed chip erase: uploading error: exit status 1

im using MiniCore bootloader.

so far i tried :

burning bootloader on:

  • my custom board
  • QFN32 breakout board
  • arduino nano with my atmga328pb

i have also tried:

  • 5 or so atmega328pb's
  • atmega328pb from different shop
  • two different uno's as ISP
  • USBsap
  • burning bootloader with and without 10uF cap to reset

my setup's:


all help is appreciated.

Second photo with Nano looks good for me but check the connections with the DMM. Sometimes wires are no reliable.

You do not need the capacitor with Arduino as ISP if you see "Using Programmer: stk500v1".
The capacitor prevents the source board from resetting but stk500v1 does not generate reset pulse.

ISP sketch is here on web for years it is OK. I am sure. You can try it with 3 monitoring LEDs for observation: hartbeat, error, programming.
https://docs.arduino.cc/built-in-examples/arduino-isp/ArduinoISP/

USBasp can have problem with the raw chip because of default internal clock settings. You have to use slow SCK. There is jumper on USBasp for this, or use the avrdude command with -B parameter to decrease the frequecy, or upload the FW into the USBasp which do this automatically. Google for more informations.
Anyway, it should work for Nano as is.

1 Like

okay, i have tried it on different computer, and indeed it works. thanks a lot.
so i have uploaded blink on the amtega328pb, and transferred it on my board.
however there is another issue, the diode on my board runs 16x slower, so the chip is running on 1MHz? even if i have 16MHz crystal.
tried:

  • different atmega328pb
  • different crystal
  • remove some components

i have another board(previous revision of the same board) and it works just fine (it has atmega328p)

  • red lines goes to amega
  • 1M resistor is above the 4-pad crystal(the crystal is between 2 and 4 pad)
  • two decoupling capacitors below the crystal

also i've tried to removing the crystal completely, and it didn't have any effect

It is possible. It depends on the fuses. You have to set them to use an external clock/crystal/resonator. There is also possibility to set the division factor. Factory default is set to internal 8MHz oscillator divided by 8, hence 1MHz.

Probably this is it. It uses internal clock because without the clock ATmega won't start. Check out the datasheet.

Another thing. R1 why? You probably took it from UNO schematics. It is not needed. In fact it can cause problems. If you do not check the oscillation on the oscilloscope, it is better to not use it.

okay... my bad, I had the crystal soldered the wrong way, so now i can upload bootloader successfully.
But now it seems like the bootloader is being erased. I got the "bootloader burned successfully" message from the arduino IDE.
The board is recognised by the computer, but when i tried to upload code i get the "avrdude urclock_getsync() warning: attempt 1 of 10: not in sync" message.
I found that if the board has bootloader the SCK diode should blink few time after reset, but my board isn't doing that.
what could cause the issue?
Could it be bad Atmega328?

yea, seen it at UNO schematic's. removed it from the board, thanks for advice.

Could you provide the details, just out of curiosity and it can help to others.

Yes, standard optiboot has this functionality 3 fast blinks at the start.

You can try to read out the flash and the fuses via ISP using avrdude. If it was possible to write something there, it should be possible to read it.

good idea. I'm using KiCad to draw my boards, and when i was selecting the footprint for my crystal (3.2mm x 2.5mm footprint) i had to edit the pad number to match my crystal, (the crystal is diagonally in the case, pin 1 and 3) and i did it the other way around. so i just rotated the crystal on the board by 90deg and its working now.

I found out that MiniCore uses Urboot bootloader which don't have to blink on reset( as far as i read) so i will try optiboot. If that wouldn't work, will try avrdude, then get back here. Thanks for your help.

Also forgot to mention that when I upload code via "Arduino as ISP", so bypass the bootloader, the code runs fine.

Just to know, once you have used ISP the bootloader is gone since the operation erases the entire flash. The bootloader has to be uploaded again.

it's working!
I have tried https://github.com/WestfW/OptiLoader arduino sketch, and it recognised the atmega328pb chip correctly, and loaded bootloader for atmega328p on it, and for some reason it works now. And now when i upload code, Arduino IDE writes it has detected atmega328p chip.
Any idea why that could be?
Anyway thanks a lot for help, I really do appreciate it.

1 Like

At the time I wrote optiLoader, there was no "core" support for the 328pb, so the "trick" was for the bootloader to identify it as an ordinary 328p. Since the pb is a superset of the p, that enabled people to use it during the "great 328p shortage"...

1 Like

Thanks for the explanation, it's very appreciated.

I have done a little app to upload .hex file for Atmega m328pb (new arduino nano) & m328p (regular nano).

Xloader doesn't support this MCU because of avrdude version.

You can give it a try :

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