Need Help Burning Bootloader on Atmega328p-au Project

Hello everyone,

I'm currently working on a project using the Atmega328p-au, and I've received the PCB. Now, I need to burn the bootloader on it, but I'm facing some difficulties.

I connected an Arduino Uno to my computer and uploaded the ArduinoISP sketch. After that, I wired the Arduino Uno to my custom board as follows:

  • VCC - Connected to 3.3V input VCC on the board (the circuit then steps up the voltage to 5V for the Atmega328p-au)
  • GND - Connected to GND on the board
  • SCK (D13) - Connected to D13 on the Atmega328p-au (using an orange jumper)
  • MISO (D12) - Connected to the RX pin on the PCB J3 Connector (using a green jumper; note that the schematic has an incorrect label)
  • MOSI (D11) - Connected to the TX pin on the PCB J3 Connector (using a blue jumper; note that the schematic has an incorrect label)
  • Reset - Connected to D10 with a 10k pull-up resistor on a breadboard (using a purple jumper; I removed the 10k SMD resistor on the board and replaced it with one on a breadboard)

In the Arduino IDE, I selected "Arduino Nano" as the board and "Arduino as ISP" as the programmer. However, when I attempt to burn the bootloader, I receive an error message:

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:\Users\Matheus Markies\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM4
         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 = 0x00fffc
avrdude: Expected signature for ATmega328P is 1E 95 0F
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

Failed chip erase: uploading error: exit status 1


The power supply part is outdated, but yes it has a 3.7 battery as an input and raises the voltage to 5v to power the arduino and other components. In addition to a 3.3v line for the nrf24l01 which now fits on an external pin bus. I disconnected the battery and connected it to the arduino's 3.3v to burn the bootloader

Can anyone offer guidance on what I might be doing wrong or how to resolve this issue? I appreciate any help you can provide.

Thank you!

Do you have any other devices on the SPI bus, that your using to program the ATMega328P ?

Did you test the whole circuit, and that you could program the ATmega328P in place, on a breadboard ?

Your NRF24L01 might interfere with the programming.

Might = Will, I think.

@Matheus_Markies I couldn't figure out from this statement whether the nRF24L01 was part of your main board or on a separate daughter board.

There's no 4x2 header for the standard nRF24L01 module, so maybe the circuitry is mounted on the underside of the PCB. The top of the PCB appears to have a ground plane which I guess won't help with the PCB antenna, but that's a separate issue maybe.

I haven't installed the NRF24L01 module yet; I've only prepared the pins to connect it later.

Unfortunately, I cannot remove the SMD ATmega328P from the PCB to test it separately on a breadboard.

Regarding the voltage readings, when using the Arduino Uno as a power supply, I measured 2.9V on pin 20 and 3.6V on pins 6, 4, and 18. However, with a battery connected, I get 5.18V on pins 6 and 4 and 0.8V on pins 18 and 20.

Currently, I'm attempting to burn the bootloader onto the ATmega328P using an Arduino Uno. Once the bootloader is successfully installed, I plan to use the ATmega328P's serial ports for programming.

Apologies for any confusion. The schematic I provided earlier was from an older version where the nRF24L01 module was integrated onto the main board. However, to simplify the design and save space, I decided to use an external nRF24L01 mini module instead. In the photo of the current board, you can see an 8x1 pin header where the external module can be connected.

Can you upload the schematic that relates to the board design you are having issues with.

Your schematic shows you are using th 328PB not the 328P
I'm pretty sure that the "use arduino as ISP" doesn't work with the PB version.

2 Likes

Please quote the the rest of what I said;

"Did you test the whole circuit, and that you could program the ATmega328P in place, on a breadboard ?"

Meaning, did you test the circuit, and in place programming before designing the PCB ?

Its quite important for the forum to know if the PCB, that does not now work, is a circuit\schematic that was previously known to work.

Unfortunately, I cannot provide the updated schematic as I wasn't the one responsible for making the changes to the project.

How can I do in this case? Use a USBasp?

Not sure. You would need to check if the USBasp supports the PB version.
I've have never used it.

Using arduino uno + battery with common ground:

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:\Users\Matheus Markies\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM4
         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 = 0x1e9516 (probably m328pb)
avrdude: Expected signature for ATmega328P is 1E 95 0F
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

Failed chip erase: uploading error: exit status 1

Using USBasp:


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:\Users\Matheus Markies\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbasp
         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 : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

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

avrdude done.  Thank you.

Failed chip erase: uploading error: exit status 1

eagle-eye @jim-p pointed out the MPU version and one possible problem. Because the 328PB is not a 328P, you will need a different core; e.g. GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB supports the 328PB.

You might try installing the Minicore core.
It supposedly can upload the bootloader for the PB version.

Sorry @sterretje was busy typing and did not see your post.

No worries; I just see it as a confirmation :wink:

+1 for the MiniCore core. That is what i use for all of my mega328 projects. Makes it easy to choose the fuse options like processor type, clock frequently, clock source, BOD setting, etc.

Installation instructions >> GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB

After making the necessary adjustments for the ATmega328PB, I received the following response:

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

         System wide configuration file is C:\Users\Matheus Markies\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1\avrdude.conf

         Using Port                    : usb
         Using Programmer              : usbasp
         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 0xff 0xff
           flash                  65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           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 : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude usbasp_spi_set_sck_period() error: cannot set sck period; please check for usbasp firmware update
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9516 (probably m328pb)
avrdude: erasing chip
avrdude: auto set sck period (because given equals null)
avrdude usbasp_spi_set_sck_period() error: cannot set sck period; please check for usbasp firmware update
avrdude: reading inpu"C:\Users\Matheus Markies\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\7.1-arduino.1/bin/avrdude" "-CC:\Users\Matheus Markies\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1/avrdude.conf" -v -patmega328pb -cusbasp  "-Uflash:w:C:\Users\Matheus Markies\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1/bootloaders/optiboot_flash/bootloaders/atmega328pb/16000000L/optiboot_flash_atmega328pb_UART0_115200_16000000L_B5.hex:i" -Ulock:w:0xcf:m
t file 0xff for lock
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lock ...
avrdude: 1 byte of lock written
avrdude: verifying lock memory against 0xff
avrdude: 1 byte of lock verified
avrdude: reading input file 0b11110101 for efuse
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte efuse ...
avrdude: 1 byte of efuse written
avrdude: verifying efuse memory against 0b11110101
avrdude: 1 byte of efuse verified
avrdude: reading input file 0b11010110 for hfuse
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte hfuse ...
avrdude: 1 byte of hfuse written
avrdude: verifying hfuse memory against 0b11010110
avrdude: 1 byte of hfuse verified
avrdude: reading input file 0b11111111 for lfuse
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lfuse ...
avrdude: 1 byte of lfuse written
avrdude: verifying lfuse memory against 0b11111111
avrdude: 1 byte of lfuse verified

avrdude done.  Thank you.


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

         System wide configuration file is C:\Users\Matheus Markies\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1\avrdude.conf

         Using Port                    : usb
         Using Programmer              : usbasp
         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 0xff 0xff
           flash                  65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           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 : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude usbasp_spi_set_sck_period() error: cannot set sck period; please check for usbasp firmware update
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9516 (probably m328pb)
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: auto set sck period (because given equals null)
avrdude usbasp_spi_set_sck_period() error: cannot set sck period; please check for usbasp firmware update
avrdude: reading input file C:\Users\Matheus Markies\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1/bootloaders/optiboot_flash/bootloaders/atmega328pb/16000000L/optiboot_flash_atmega328pb_UART0_115200_16000000L_B5.hex for flash
         with 484 bytes in 2 sections within [0x7e00, 0x7fff]
         using 4 pages and 28 pad bytes
avrdude: writing 484 bytes flash ...

Writing | ################################################## | 100% 0.07s

avrdude: 484 bytes of flash written
avrdude: verifying flash memory against C:\Users\Matheus Markies\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1/bootloaders/optiboot_flash/bootloaders/atmega328pb/16000000L/optiboot_flash_atmega328pb_UART0_115200_16000000L_B5.hex

Reading | ################################################## | 100% 0.00s

avrdude: 484 bytes of flash verified
avrdude: reading input file 0xcf for lock
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lock ...
avrdude: 1 byte of lock written
avrdude: verifying lock memory against 0xcf
avrdude: 1 byte of lock verified

avrdude done.  Thank you.

Do you think it worked?
And there's this SCK error: avrdude usbasp_spi_set_sck_period() error: cannot set sck period; please check for usbasp firmware update

Is there any way to record the codes in atmega by USBasp?

If it says done and thank you then i worked.
You should have put an LED on the board that you could blink to at least check if an uploaded program is actually running