How to burn bootloader into ATMega328PB ?

I’ve made a new scratch-built board with an ATMega328PB on it. My Arduino environment is 1.6.7 on Mac OS X. The ordinary procedure for burning a bootloader onto an Arduino Uno r3 is not working. The error given is “avrdude: Expected signature for ATmega328P is 1E 95 0F”. Indeed the signature of the ATMega328PB is different. From the forum here and the chip documentation, I’ve found the new part’s signature. As described in some posts, I’ve added some lines in the avrdude.conf file for the new chip to be handled: (shown below). These lines seem to have no effect. What is wrong?
Also, I’ve tried doing as the error message recommends-- putting a ‘-F’ on the command line for avrdude. But this doesn’t work either. I have been quitting and restarting Arduino. But the changes seem to have no effect. All I need to do at this point is burn the bootloader. How should I proceed?

part parent “m328”
id = “m328p”;
desc = “ATmega328P”;
signature = 0x1e 0x95 0x0F;

ocdrev = 1;
;

part parent “m328”
id = “m328pb”;
desc = “ATmega328PB”;
signature = 0x1e 0x95 0x16;

ocdrev = 1;
;

And then I tried submitting a command line directly from a Terminal window:

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328pb -cstk500v2 -P/dev/cu.usbmodem1d1111 -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xd8:m -Ulfuse:w:0xff:m

avrdude: Version 6.0.1, compiled on Apr 14 2015 at 16:30:25
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is “/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf”
User configuration file is “/Volumes/Macintosh HD_storage/Users/mark/.avrduderc”
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/cu.usbmodem1d1111
Using Programmer : stk500v2
avrdude: stk500v2_ReceiveMessage(): timeout
^C

dmjlambert:
GitHub - WestfW/OptiLoader: Arduino sketch for burning new bootloaders

This method will work to use the 328PB chip backwards compatible as regular 328p within the arduino IDE, as it seems to load the regular 328p bootloader. When uploading sketches this way, the bootloader reports the signature of the 328p, not the 328pb, so you don't gain any new functionality of the new chip. This can be useful if you are populating your boards with the 328PB for future expanded functionality, but still running firmware for the 328p chips...

However, if you want to use the new features with the 328PB, I was able to get some of it working (specifically the 2nd UART) by doing the following:

  1. go here and download & OVERWRITE your avr-gcc toolchain to 4.9.2 within your arduino directory.
    GitHub - watterott/ATmega328PB-Testing: Atmel/Microchip ATmega328PB support for Arduino IDE

  2. add the custom files for 328PB from that same repository

  3. modify the boards.txt within that repository to ensure the bootloader points to the bootloader that came with it. I don't believe mine did.

  4. use the arduino as ISP sketch on a regular UNO to burn the 328PB optiboot bootloader to your new chip.

  5. now you can use an FTDI programmer to load sketches onto the new board directly, and I can comfirm both serial ports are working. I did not test anything else new to the PB.

note: i am using a regular 16mhz crystal oscilator, the kind with 4 pads in a 3225 package. There is discussion of problems with the 328PB on other threads using certain kinds of crystals, but i can confirm this kind works at 16mhz and some 22pf caps..
digikey similar part

Hi miketedeschi,

I followed your method to write the bootloader into a board I have made with a 328pb.
I can load the blink sketch with the Arduino IDE, but after that the 328pb seems not to accept any other load by the IDE, while the led is blinking normally.
In place, I receive the 'avrdude: stk500_recv(): programmer is not responding'...

I can reload the sketch ONLY if I write the bootloader again after the processor flash has been cleared.

Do you have an idea?

Is it possible to obtain the source code of the bootloader?

I use a similar crystal at 16MHz without problems. All seems to work great.

Best regards....

I gave up hacking things to get the 328PB working as a "PB" because the above broke the eeprom library.

I remember experiencing something similar, and I think it has something to do with the new arduino IDE constantly polls the serial ports to report the kind of arduino board that is connected. It may not like a 328PB combined with a cheap FTDI breakout.

I'm curious if you pulled the atmega328P-pu off an arduino uno, and used the uno as usb-serial. 5v, Gnd, rx, TX direct, but do the 328PB to pin 10 on arduino. It might help fake out the arduino ide?

If all else fails, you can use the optiloader sketch to turn the 328PB into a regular 328P (as far as the arduino IDE is concerned)

Hopefully there will be a 328PB solution soon that just works nicely...

The serial polling bug is fixed in the hourly 1.6.9 builds, and isn't present in 1.6.7. And I think it was only ever an issue on windows. So that's an easy issue to avoid.

I will try the 1.6.9 for Windows next days.....

And yes, a 328pb solution for Arduino would be cool. The two serial ports of the 'pb' are very interesting....

Yeah - I think what's holding people back is the need to update the compiler. Once Arduino is on version that works with it out of the box, I think you'll see a wave of development effort for it in the community - because it's an incredible chip, basically a '328p (already everyone's favorite chip) with the biggest shortcoming addressed

OK, it seems to work fine (blink sketch)

I use:

ATMEL ATmega328pb
FTDI FT230X
ARDUINO IDE VER 1.6.9 (2016/05/06)
GCC VER 4.9.2 (Atmel AVR 8-bit Toolchain 3.5.1 - Windows from Smart | Connected | Secure | Microchip Technology)

The mods GitHub - watterott/ATmega328PB-Testing: Atmel/Microchip ATmega328PB support for Arduino IDE

My original mistake :

I placed a capacitor between the RTS pin of the FT230X and the RESET pin of the 328pb.
With a 1K resistor in place, it works... better!

Erfly44, try including the EEPROM library and see if it compiles.

I got it to compile with the second Uart working, but if I added eeprom it failed to compile.

Interesting about the RTS…

Ok miketedeschi.

I will try next week.....

Hi miketedeschi and all,

Simply copy the ..\hardware\tools\avr\avr\lib\avr5\libc.a from the V1.6.8 for exemple (1263KB) in place of this same directory in the Arduino distribution (1.6.9 for me) where you have placed the latest Atmel Gcc toolchain (232KB).

No compliation errors for the EEPROM after this...
I have not yet tested the result into my ATmega328pb processor board. I will do that... next days...
Do not hesitate to do that....

Enjoy.

Eric

Thanks Eric, I'll try that and report back. I have a new PCB arriving today that's for the 328PB. I can't wait to move the RS485 to the 2nd UART so that UART0 can upload/debug to serial monitor...

I understand, I use, in a same way, an isolated RS485 to do the interface between a Controllino and a graphical color lcd display… I intend to ‘play’ with this week, if I have time…

A picture of my card at the end of the article (in French, sorry) :

Best regards.

Eric

dmjlambert:
GitHub - WestfW/OptiLoader: Arduino sketch for burning new bootloaders

Hi,

Tried this. Getting the following error. Please help. Thanks!

Arduino: 1.8.12 (Windows 10), Board: “ATmega328PB Internal Clock, 8 MHz”

sketch_may02b:239:3: error: ‘SPCR’ was not declared in this scope

SPCR = 0x53; // SPIE | MSTR | SPR1 | SPR0

^~~~

C:\Users\hp\Documents\Arduino\sketch_may02b\sketch_may02b.ino:239:3: note: suggested alternative: ‘SPCR0’

SPCR = 0x53; // SPIE | MSTR | SPR1 | SPR0

^~~~

SPCR0

sketch_may02b:240:7: error: ‘SPSR’ was not declared in this scope

x = SPSR;

^~~~

C:\Users\hp\Documents\Arduino\sketch_may02b\sketch_may02b.ino:240:7: note: suggested alternative: ‘SPSR0’

x = SPSR;

^~~~

SPSR0

sketch_may02b:241:7: error: ‘SPDR’ was not declared in this scope

x = SPDR;

^~~~

C:\Users\hp\Documents\Arduino\sketch_may02b\sketch_may02b.ino:241:7: note: suggested alternative: ‘SPDR0’

x = SPDR;

^~~~

SPDR0

C:\Users\hp\Documents\Arduino\sketch_may02b\sketch_may02b.ino: In function ‘void spi_wait()’:

sketch_may02b:252:12: error: ‘SPSR’ was not declared in this scope

while (!(SPSR & (1 << SPIF)));

^~~~

C:\Users\hp\Documents\Arduino\sketch_may02b\sketch_may02b.ino:252:12: note: suggested alternative: ‘SPSR0’

while (!(SPSR & (1 << SPIF)));

^~~~

SPSR0

C:\Users\hp\Documents\Arduino\sketch_may02b\sketch_may02b.ino: In function ‘uint8_t spi_send(uint8_t)’:

sketch_may02b:261:3: error: ‘SPDR’ was not declared in this scope

SPDR = b;

^~~~

C:\Users\hp\Documents\Arduino\sketch_may02b\sketch_may02b.ino:261:3: note: suggested alternative: ‘SPDR0’

SPDR = b;

^~~~

SPDR0

C:\Users\hp\Documents\Arduino\sketch_may02b\sketch_may02b.ino: In function ‘void end_pmode()’:

sketch_may02b:331:3: error: ‘SPCR’ was not declared in this scope

SPCR = 0; /* reset SPI */

^~~~

C:\Users\hp\Documents\Arduino\sketch_may02b\sketch_may02b.ino:331:3: note: suggested alternative: ‘SPCR0’

SPCR = 0; /* reset SPI */

^~~~

SPCR0

Using library OptiLoader-master in folder: C:\Users\hp\Documents\Arduino\libraries\OptiLoader-master (legacy)
exit status 1
‘SPCR’ was not declared in this scope

Is this just when you're trying to burn the bootloader?

BJHenry:
Is this just when you’re trying to burn the bootloader?

Hi,
Thanks for your time.
I am unsure if i got what you are asking.
This error is showing up when i am trying to upload the optiLoader.ino sketch onto an ATmega328pb dev board using Arduino as ISP.

Also, i am sorry for putting the error message in a miserable way in my last post. I have learnt using code tags. I will post it again here.

Arduino: 1.8.12 (Windows 10), Board: "ATmega328PB Internal Clock, 1 MHz"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\hp\AppData\Local\Arduino15\packages -hardware C:\Users\hp\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\hp\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\hp\Documents\Arduino\libraries -fqbn=m328pb:avr:atmega328pbic:speed=1mhz -vid-pid=0X2341_0X0043 -ide-version=10812 -build-path C:\Arduino-Output -warnings=none -build-cache C:\Users\hp\AppData\Local\Temp\arduino_cache_106542 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\hp\AppData\Local\Arduino15\packages -hardware C:\Users\hp\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\hp\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\hp\Documents\Arduino\libraries -fqbn=m328pb:avr:atmega328pbic:speed=1mhz -vid-pid=0X2341_0X0043 -ide-version=10812 -build-path C:\Arduino-Output -warnings=none -build-cache C:\Users\hp\AppData\Local\Temp\arduino_cache_106542 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino
Using board 'atmega328pbic' from platform in folder: C:\Users\hp\AppData\Local\Arduino15\packages\m328pb\hardware\avr\1.1.4
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328pb -DF_CPU=1000000L -DARDUINO=10812 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Users\\hp\\AppData\\Local\\Arduino15\\packages\\m328pb\\hardware\\avr\\1.1.4\\variants\\atmega328pb" "C:\\Arduino-Output\\sketch\\optiLoader.ino.cpp" -o nul
Alternatives for optiLoader.h: [OptiLoader-master]
ResolveLibrary(optiLoader.h)
  -> candidates: [OptiLoader-master]
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328pb -DF_CPU=1000000L -DARDUINO=10812 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Users\\hp\\AppData\\Local\\Arduino15\\packages\\m328pb\\hardware\\avr\\1.1.4\\variants\\atmega328pb" "-IC:\\Users\\hp\\Documents\\Arduino\\libraries\\OptiLoader-master" "C:\\Arduino-Output\\sketch\\optiLoader.ino.cpp" -o nul
Generating function prototypes...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=atmega328pb -DF_CPU=1000000L -DARDUINO=10812 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Users\\hp\\AppData\\Local\\Arduino15\\packages\\m328pb\\hardware\\avr\\1.1.4\\variants\\atmega328pb" "-IC:\\Users\\hp\\Documents\\Arduino\\libraries\\OptiLoader-master" "C:\\Arduino-Output\\sketch\\optiLoader.ino.cpp" -o "C:\\Arduino-Output\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Arduino-Output\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328pb -DF_CPU=1000000L -DARDUINO=10812 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Users\\hp\\AppData\\Local\\Arduino15\\packages\\m328pb\\hardware\\avr\\1.1.4\\variants\\atmega328pb" "-IC:\\Users\\hp\\Documents\\Arduino\\libraries\\OptiLoader-master" "C:\\Arduino-Output\\sketch\\optiLoader.ino.cpp" -o "C:\\Arduino-Output\\sketch\\optiLoader.ino.cpp.o"
C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino: In function 'void spi_init()':

optiLoader:239:3: error: 'SPCR' was not declared in this scope

   SPCR = 0x53;  // SPIE | MSTR | SPR1 | SPR0

   ^~~~

C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino:239:3: note: suggested alternative: 'SPCR0'

   SPCR = 0x53;  // SPIE | MSTR | SPR1 | SPR0

   ^~~~

   SPCR0

optiLoader:240:7: error: 'SPSR' was not declared in this scope

   x = SPSR;

       ^~~~

C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino:240:7: note: suggested alternative: 'SPSR0'

   x = SPSR;

       ^~~~

       SPSR0

optiLoader:241:7: error: 'SPDR' was not declared in this scope

   x = SPDR;

       ^~~~

C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino:241:7: note: suggested alternative: 'SPDR0'

   x = SPDR;

       ^~~~

       SPDR0

C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino: In function 'void spi_wait()':

optiLoader:252:12: error: 'SPSR' was not declared in this scope

   while (!(SPSR & (1 << SPIF)));

            ^~~~

C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino:252:12: note: suggested alternative: 'SPSR0'

   while (!(SPSR & (1 << SPIF)));

            ^~~~

            SPSR0

C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino: In function 'uint8_t spi_send(uint8_t)':

optiLoader:261:3: error: 'SPDR' was not declared in this scope

   SPDR = b;

   ^~~~

C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino:261:3: note: suggested alternative: 'SPDR0'

   SPDR = b;

   ^~~~

   SPDR0

C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino: In function 'void end_pmode()':

optiLoader:331:3: error: 'SPCR' was not declared in this scope

   SPCR = 0;         /* reset SPI */

   ^~~~

C:\Users\hp\Documents\Arduino\optiLoader\optiLoader.ino:331:3: note: suggested alternative: 'SPCR0'

   SPCR = 0;         /* reset SPI */

   ^~~~

   SPCR0

Using library OptiLoader-master in folder: C:\Users\hp\Documents\Arduino\libraries\OptiLoader-master (legacy)
exit status 1
'SPCR' was not declared in this scope

Ok, that makes a lot more sense now. I wouldn't bother trying to burn the bootloader using a sketch like that- just connect everything up, select the ATMega328PB, and go Tools->Burn Bootloader.
What programmer are you using?

BJHenry:
Ok, that makes a lot more sense now. I wouldn’t bother trying to burn the bootloader using a sketch like that- just connect everything up, select the ATMega328PB, and go Tools->Burn Bootloader.
What programmer are you using?

Hi,

I have done that before, began with the basic bootloading procedure as you mentioned. It gave error and couldn’t detect the device signature. I will attach the error here.
So i went forward to look for other options to get the bootloader burnt onto the ATmega328pb chip, and found the optiLoader sketch. So tried uploading it to the board.

Programmer: Arduino as ISP

Arduino: 1.8.12 (Windows 10), Board: "ATmega328PB Internal Clock, 1 MHz"

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude.exe -CC:\Users\hp\AppData\Local\Arduino15\packages\m328pb\hardware\avr\1.1.4/tools/avrdude.conf -v -patmega328pb -cstk500v1 -PCOM8 -b19200 -e -Ulock:w:0xFF:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD6:m -Ulfuse:w:0x62:m 

avrdude.exe: 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:\Users\hp\AppData\Local\Arduino15\packages\m328pb\hardware\avr\1.1.4/tools/avrdude.conf"

             Using Port                    : COM8
             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
               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.exe: AVR device initialized and ready to accept instructions

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

avrdude.exe: Device signature = 0x000000 (retrying)

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

avrdude.exe: Device signature = 0x000000 (retrying)

Error while burning bootloader.
Reading | ################################################## | 100% 0.02s

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


avrdude.exe done.  Thank you.

Optiloader is a sketch that runs on a regular Uno-style Arduino (ATmega328p or ATmega168), which makes it able to program the bootloader into several other types of CPU (ATmega8, ATmega168, ATmega328p, ATmega328, ATmega328pb.) You don’t specifically compile it for the final target CPU, and it was never updated to compile for a 328pb

Also, at this point Optiloader is quite old - it’s 328pb support consisted of burning a 328p bootloader and letting the target “pretend” to be just a 328p. That was sufficient for using the PB as P replacement, but not of accessing any of the new features (the core and Arduino compiler didn’t support the PB at that time, anyway.) Now that the compiler is upgraded and MiniCore fully supports the PB (and has a real PB bootloader), that would be the preferred path.

avrdude.exe: Device signature = 0x000000

In any case, “invalid signature” messages like this have nothing to do with the bootloader itself, but indicate some sort of hardware problem - bad programming connections (bad cable? Incorrectly inserted?), conflicts with other connections to the programming pins, or fuse settings that don’t match the hardware (ie for “external crystal” when there isn’t one, or “external clock” when it should be “external crystal.”) (The default clock should be the internal oscillator. So brand new chips should show something.)