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
@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.
+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.
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