Arduino nano as ISP does not work

I burn Arduino nano(328p) as ISP, in Arduino IDE test firmware uploaded to the target board and everything works. In Paltformio created a configuration according to the documentation, on the forum has been discussed many times, I checked everything, I can’t find any errors. Please explain what I am doing wrong.

[platformio]
src_dir = src_isp_test

; pio run -e isp_test -t upload
[env:isp_test]
platform = atmelavr
framework = arduino
board = nanoatmega328
upload_protocol = custom
upload_port = /dev/tty.usbserial-1430  
upload_speed = 115200

upload_flags =
    -C
    ; use "tool-avrdude-megaavr" for the atmelmegaavr platform
    ${platformio.packages_dir}/tool-avrdude/avrdude.conf
    -p$BOARD_MCU
    -P$UPLOAD_PORT
    -b$UPLOAD_SPEED
    -cstk500v1 ;stk500v1
    -b19200
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

;   arduinoisp       = Arduino ISP Programmer
;   arduinoisporg    = Arduino ISP Programmer
;   avrisp           = Atmel AVR ISP
;   avrisp2          = Atmel AVR ISP mkII
;   avrispmkII       = Atmel AVR ISP mkII
;   avrispv2         = Atmel AVR ISP V2

Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [ ] 0.4% (used 9 bytes from 2048 bytes)
Flash: [ ] 3.4% (used 1032 bytes from 30720 bytes)
Building .pio/build/isp_test/firmware.hex
Configuring upload protocol…
AVAILABLE: custom
CURRENT: upload_protocol = custom
Uploading .pio/build/isp_test/firmware.hex
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00

Half a day of my life is spent, and there is no result :sob:

When I open the ArduinoISP sketch in my Arduino IDE, I see

#define BAUDRATE	19200
// #define BAUDRATE	115200
// #define BAUDRATE	1000000

so if you didn’t change that, you need to set upload_speed = 19200

The -b parameter is set twice? o_O

Oh, sorry for the confusion, the b parameter it’s a failed test, I changed the speed from 19200 to 115200 in the hope of a miracle.
And of course I tried everything in the frame.

Then let’s just go the absolute easiest way possible:
In the Arduino IDE, go to File → Preferences → activate “Verbose Upload”.

Upload a test firmware again via the Arduino IDE. What is the exact avrdude invocation?

avrdude: Version 6.3-20201216
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/Users/pavluchenko/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino18/etc/avrdude.conf"
         User configuration file is "/Users/pavluchenko/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbserial-1430
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
         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 : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.16
         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.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "/private/var/folders/1r/4jl13l9d1kgg9fz7f_55_pb00000gn/T/arduino-sketch-035BCA8AFD83C4E87C2A29C2B2AD8F33/Blink.ino.hex"
avrdude: writing flash (928 bytes):

Writing | ################################################## | 100% 0.32s

avrdude: 928 bytes of flash written

avrdude done.  Thank you.

So that’s the right baud rate.

It works!
I was moving down from 19200 and had no idea that such a solution was possible!
Thank you very much for your professionalism!
P.S. And now I will flash the bootloader :rofl:
I am working on an open source project and I want the user to first change the config.h, prepare himself a programmer, then replace the bootloader on the target board and then flash it with the main firmware. The day off is not lost!

1 Like

I tried the standard ArduinoISP from Arduino IDE and this interesting example, burning the target board works, but I can’t access the fuses. Does this work at all or do I need a programmer for this purpose?

I’m afraid so. To burn a bootloader, change fuses or upload an eep (EEPROM data) file requires an ISP device.

However, having said that, it should work using the Arduino as ISP sketch because that turns your Nano into an ISP device.

Cheers,
Norm.

I’ve figured out the symptoms a little bit, but I don’t understand the problem.
I have:

And I bought yesterday a USBASP programmer, I will not list all the steps, there were many, but there is a result
Mac OS, avrdude, terminal app
Arduino UNO: read fuses, can write firmware
Arduino NANO: can’t read fuses, can’t write firmware

Similar in platformo and Arduino IDE
There are two different Arduino NANO but I can’t read the fuses on both of them. I changed the key -p avrdude -c usbasp -p m328 -P usb -b 19200 -v -F -U hfuse:r:-:h -U lfuse:r:-:h -U efuse:r:-:h to all variants m328, m328p, m328pb

And so, all this terrible problem was my ignorance, as it turned out, the Arduino nano has two hardware revisions. With the correct pinout everything works, fuses read, bootloader updated, uploading firmware via usbasp works.

Now I’m asking for help again.
For some unknown reason I can not upload firmware via USB. Apparently, I once again am missing some nuance. Bootloader MiniCore.

[platformio]
;default_envs = nanoatmega328new
default_envs = Upload_UART

[env]
platform = atmelavr
framework = arduino
board = ATmega328P
board_build.f_cpu = 16000000L
build_unflags = -flto
build_flags = 
monitor_port = ${env:Upload_UART.upload_port}
monitor_speed = 9600

[env:Upload_UART]
upload_protocol = arduino
upload_port = /dev/tty.usbserial-1430
board_upload.speed = ${env:fuses_bootloader.board_bootloader.speed}


[env:Upload_ISP]
upload_protocol = custom
upload_flags =
  -C$PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
  -p$BOARD_MCU
  -PUSB
  -cusbasp
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i


; Run the following command to set fuses
; pio run -e fuses_bootloader -t fuses
; Run the following command to set fuses + burn bootloader
; pio run -e fuses_bootloader -t bootloader
[env:fuses_bootloader]
board_hardware.oscillator = external ; Oscillator type
board_hardware.uart = uart0          ; Set UART to use for serial upload
board_bootloader.speed = 115200      ; Set bootloader baud rate
board_hardware.bod = 2.7v            ; Set brown-out detection
board_hardware.eesave = yes          ; Preserve EEPROM when uploading using programmer
upload_protocol = usbasp             ; Use the USBasp as programmer
upload_flags =                       ; Select USB as upload port and divide the SPI clock by 8
  -PUSB
  -B8

Terminal output

***********************************************************************************************************************************************************************************************************************************************************************************************************************************
Obsolete PIO Core v6.1.5 is used (previous was 6.1.6)
Please remove multiple PIO Cores from a system:
https://docs.platformio.org/en/latest/core/installation/troubleshooting.html
***********************************************************************************************************************************************************************************************************************************************************************************************************************************
Processing Upload_UART (platform: atmelavr; framework: arduino; board: ATmega328P)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/ATmega328P.html
PLATFORM: Atmel AVR (3.4.0) > ATmega328P/PA
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 32KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr-minicore @ 2.1.3 
 - tool-avrdude @ 1.60300.200527 (6.3.0) 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
Converting fuse.ino
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 38 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/Upload_UART/src/fuse.ino.cpp.o
Compiling .pio/build/Upload_UART/src/pidautotuner.cpp.o
Archiving .pio/build/Upload_UART/libFrameworkArduinoVariant.a
Indexing .pio/build/Upload_UART/libFrameworkArduinoVariant.a
Compiling .pio/build/Upload_UART/FrameworkArduino/CDC.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/HardwareSerial0.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/HardwareSerial1.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/HardwareSerial2.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/HardwareSerial3.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/IPAddress.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/PluggableUSB.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/Print.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/Tone.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/USBCore.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/WInterrupts.c.o
Compiling .pio/build/Upload_UART/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/WString.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/abi.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/hooks.c.o
Compiling .pio/build/Upload_UART/FrameworkArduino/main.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/new.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/wiring.c.o
Compiling .pio/build/Upload_UART/FrameworkArduino/wiring_analog.c.o
Compiling .pio/build/Upload_UART/FrameworkArduino/wiring_digital.c.o
Compiling .pio/build/Upload_UART/FrameworkArduino/wiring_extras.cpp.o
Compiling .pio/build/Upload_UART/FrameworkArduino/wiring_pulse.S.o
Compiling .pio/build/Upload_UART/FrameworkArduino/wiring_pulse.c.o
Compiling .pio/build/Upload_UART/FrameworkArduino/wiring_shift.c.o
Archiving .pio/build/Upload_UART/libFrameworkArduino.a
Indexing .pio/build/Upload_UART/libFrameworkArduino.a
Linking .pio/build/Upload_UART/firmware.elf
Checking size .pio/build/Upload_UART/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  10.6% (used 218 bytes from 2048 bytes)
Flash: [=         ]   6.2% (used 2016 bytes from 32256 bytes)
Building .pio/build/Upload_UART/firmware.hex
Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...
Using manually specified: /dev/tty.usbserial-1430
Uploading .pio/build/Upload_UART/firmware.hex
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00