After intensively searching on this forum and on others as well, I unfortunately didn't find a solution to my problem. After successfully installing a bootloader to my Arduino Nano (ATmega328PB, some kind of a clone), I don't seem to be able to upload any sketch directly to it. I can, instead, do it through my programmer board (Mega 2560) using the "Upload using programmer" feature. I'll replicate all the steps I've done:
I uploaded the ArduinoISP sketch from Examples > ArduinoISP to the Mega board
After uploading, I put a 100mF capacitor between the RESET and GND pin on Mega
I physically connected the two boards like this:
Pin 10 Mega -> Pin RESET Nano
Pin 50 Mega -> Pin 12 Nano
Pin 51 Mega -> Pin 11 Nano
Pin 52 Mega -> Pin 13 Nano
5V Mega -> 5V Nano
GND Mega -> GND Nano
I selected all the options about the ATmega328PB under the Tools menu. Port also.
I set the programmer to "Arduino as ISP"
After these steps, I clicked on "Burn Bootloader" and it installed successfully.
I select the ATmega328 board from the Board and its relevant settings about the 328PB
I set the programmer back to AVRISP mkll.
At this point, I am expecting to be able to disconnect the Nano from the Mega and be able to use it standalone, i.e. to be able to upload sketches directly to it. But unfortunately I cannot.
When I connect it using its own USB cable, I see its port under the Ports menu. I'm on a Mac, it says something like "/dev/cu/usbserial-1410". But when I try to upload the "Blink" sketch, I get these errors:
Sketch uses 528 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
"/Users/myusername/Library/Arduino15/packages/MiniCore/tools/avrdude/7.1-arduino.1/bin/avrdude" "-C/Users/myusername/Library/Arduino15/packages/MiniCore/hardware/avr/2.2.2/avrdude.conf" -v -V -patmega328pb -carduino -P/dev/cu.usbserial-1410 -b115200 -D "-Uflash:w:/private/var/folders/ld/y0z1bg0n6z92c9hz6xmltpdc0000gn/T/arduino/sketches/97074686CE82DDC813DB116D8286818A/Blink.ino.hex:i"
avrdude: Version 7.1-arduino.1
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is /Users/myusername/Library/Arduino15/packages/MiniCore/hardware/avr/2.2.2/avrdude.conf
User configuration file is /Users/myusername/.avrduderc
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/cu.usbserial-1410
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 1 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 2 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 3 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 4 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 5 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 6 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 7 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 8 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 9 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 10 of 10: not in sync: resp=0x00
avrdude main() error: unable to open programmer arduino on port /dev/cu.usbserial-1410
avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
At this point, I really don't know what to do next. Am I wrong to expect it to work? I searched a lot on the web but I didn't succeed to find anything helpful. Please tell me if I'm doing something wrong. Any help is appreciated.
When you do that, the bootloader is erased. So if you have done an "Upload using programmer", it is required to do another "Burn Bootloader" operation before you can go back to uploading via the serial port of the board as usual again.
Hi @ptillisch , thank you for your answer. I actually didn't know that.
Now I'm trying to burn the bootloader again, but it seems that now even that doesn't work! Here are the errors:
"/home/username/.arduino15/packages/MiniCore/tools/avrdude/7.1-arduino.1/bin/avrdude" "-C/home/username/.arduino15/packages/MiniCore/hardware/avr/2.2.2/avrdude.conf" -v -patmega328pb -cstk500v1 -P/dev/ttyACM0 -b19200 -e -Ulock:w:0xff:m -Uefuse:w:0b11110100:m -Uhfuse:w:0b11010110:m -Ulfuse:w:0b11111111:m
avrdude: Version 7.1-arduino.1
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is /home/username/.arduino15/packages/MiniCore/hardware/avr/2.2.2/avrdude.conf
User configuration file is /home/username/.avrduderc
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyACM0
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 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 : 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
I think that's a connection problem, but I've triple checked the connections, I've tried both putting the Nano on breadboard and directly connect it to the Mega with jumpers, but to no avail.
I checked the connections electrically with a multimeter, and there's 100% connection. For some reason it won't work.
I tried with a 22mF capacitor - no effect.
Tried with selection of board Tools > Board > Arduino AVR Boards > Arduino Nano and then Tools > Processor > ATmega328P (Old Bootloader) - no effect.
Tried with completely different jumpers - no effect.
Tried uncommenting this line in the "ArduinoISP" sketch // #define USE_OLD_STYLE_WIRING - no effect.
Maybe I should try with another programmer board, but I only have a Leonardo and I didn't find the right connections for it. If someone has them, please share them.
There is a problem with using ATmega32U4-based boards like the Leonardo as an "Arduino as ISP" programmer:
A special "Arduino as ISP (ATmega32U4)" programmer definition to allow use of boards like the Leonardo as a programmer was added to the "Arduino AVR Boards" platform:
But I see that an equivalent programmer definition was never added to MiniCore.
You mentioned that you were using a Mega 2560 as a programmer in your first post:
Do you still have access to that Mega 2560 board? If so, do you get different results if you use that one as the "Arduino as ISP" programmer board instead of the Leonardo?
The connections depend on whether or not you have the #define USE_OLD_STYLE_WIRING line uncommented. Here are the connections to use if the line is commented as is the case with the unmodified "ArduinoISP" sketch:
Programmer
Target
CIPO
CIPO
VCC
5V (VCC on 3.3 V boards)
SCK
SCK
COPI
COPI
10
RESET
GND
GND
The "CIPO" pin was formerly referred to as "MISO" and the "COPI" pin formerly referred to as "MOSI"
The CIPO, SCK, and COPI pins are on the ICSP header on the Leonardo board:
It seems I managed to install the bootloader correctly again. This is the output:
"/Users/robertstamenkov/Library/Arduino15/packages/MiniCore/tools/avrdude/7.1-arduino.1/bin/avrdude" "-C/Users/robertstamenkov/Library/Arduino15/packages/MiniCore/hardware/avr/2.2.2/avrdude.conf" -v -patmega328pb -cstk500v1 -P/dev/cu.usbmodem14201 -b19200 -e -Ulock:w:0xff:m -Uefuse:w:0b11110100:m -Uhfuse:w:0b11010110:m -Ulfuse:w:0b11111111:m
avrdude: Version 7.1-arduino.1
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is /Users/robertstamenkov/Library/Arduino15/packages/MiniCore/hardware/avr/2.2.2/avrdude.conf
User configuration file is /Users/robertstamenkov/.avrduderc
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/cu.usbmodem14201
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 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 : 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 = 0x1e9516 (probably m328pb)
avrdude: erasing chip
avrdude: reading input 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 0b11110100 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 0b11110100
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 ...
"/Users/robertstamenkov/Library/Arduino15/packages/MiniCore/tools/avrdude/7.1-arduino.1/bin/avrdude" "-C/Users/robertstamenkov/Library/Arduino15/packages/MiniCore/hardware/avr/2.2.2/avrdude.conf" -v -patmega328pb -cstk500v1 -P/dev/cu.usbmodem14201 -b19200 "-Uflash:w:/Users/robertstamenkov/Library/Arduino15/packages/MiniCore/hardware/avr/2.2.2/bootloaders/optiboot_flash/bootloaders/atmega328pb/16000000L/optiboot_flash_atmega328pb_UART1_115200_16000000L_B5.hex:i" -Ulock:w:0xcf:m
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 /Users/robertstamenkov/Library/Arduino15/packages/MiniCore/hardware/avr/2.2.2/avrdude.conf
User configuration file is /Users/robertstamenkov/.avrduderc
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/cu.usbmodem14201
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 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 : 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 = 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: reading input file /Users/robertstamenkov/Library/Arduino15/packages/MiniCore/hardware/avr/2.2.2/bootloaders/optiboot_flash/bootloaders/atmega328pb/16000000L/optiboot_flash_atmega328pb_UART1_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.08s
avrdude: 484 bytes of flash written
avrdude: verifying flash memory against /Users/robertstamenkov/Library/Arduino15/packages/MiniCore/hardware/avr/2.2.2/bootloaders/optiboot_flash/bootloaders/atmega328pb/16000000L/optiboot_flash_atmega328pb_UART1_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.
The LED on the Nano starts to flash continuously (I don't know if that's the expected behaviour). After that, when I disconnect it from the Mega (which I used as a programmer board) and I connect it to the PC with its own cable, the flashing stops until I select its port on the Arduino IDE. After I select the port, it starts to flash twice on intervals of 1-2 seconds.
At this point, I tried to upload the sketch "DigitalReadSerial.ino". This is what I got:
Sketch uses 2798 bytes (8%) of program storage space. Maximum is 32256 bytes.
Global variables use 190 bytes (9%) of dynamic memory, leaving 1858 bytes for local variables. Maximum is 2048 bytes.
"/Users/robertstamenkov/Library/Arduino15/packages/MiniCore/tools/avrdude/7.1-arduino.1/bin/avrdude" "-C/Users/robertstamenkov/Library/Arduino15/packages/MiniCore/hardware/avr/2.2.2/avrdude.conf" -v -V -patmega328pb -carduino -P/dev/cu.usbserial-1420 -b115200 -D "-Uflash:w:/private/var/folders/ld/y0z1bg0n6z92c9hz6xmltpdc0000gn/T/arduino/sketches/8ADEE28AC432B81370E8A8937E698DA9/DigitalReadSerial.ino.hex:i"
avrdude: Version 7.1-arduino.1
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is /Users/robertstamenkov/Library/Arduino15/packages/MiniCore/hardware/avr/2.2.2/avrdude.conf
User configuration file is /Users/robertstamenkov/.avrduderc
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/cu.usbserial-1420
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 1 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 2 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 3 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 4 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 5 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 6 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 7 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 8 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 9 of 10: not in sync: resp=0x00
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 10 of 10: not in sync: resp=0x00
avrdude main() error: unable to open programmer arduino on port /dev/cu.usbserial-1420
avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
I tried putting a 100uF capacitor between the RESET and GND pins but I still get the same error.
Please remove that and then try uploading to the board again.
It is sometimes necessary to add such a capacitor to the programmer board when performing a "Burn Bootloader" operation using an "Arduino as ISP" programmer, but it will interfere with the upload process if you have it on a board that you are trying to upload to. The error message you reported is actually expected for subsequent uploads when you have this capacitor in place.
I had tried both with and without the capacitor, and I had gotten the same error. I actually tried first without the capacitor. I also tried with another USB cable but still got the same results.
Theoretically, after burning the bootloader, I should be able to upload sketches normally to the board, right? Or I'm missing something?