Arduino IDE failing to load program into Nano

Hello,

I have a few Arduinos, UNO/Nano/Mini/Mega, and a few PCs and up until now everything loads fine. Today the IDE failed to load the program into a Nano. That project had been loaded into that Nano many times before. I've tried lots of things:

  • new project - blink - same, won't load.
  • another Nano - same, won't load.
  • another PC - good, can load, both Nanos.
  • use Putty on the com port - good println output (from program loaded with other pc).
  • re-install Arduino software 1.8.7 -> 1.8.8 - no help, same problem.

Then I looked at the error messages:

Using Port : COM17
Using Programmer : arduino
Overriding Baud Rate : 115200

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x60
(sometimes it was resp=0x00)

and I thought that was the wrong baud rate, so tried using a command file to load, at 57600 - Success!

@rem Arduino build from command line.
@rem https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc
@rem Put this file in the Arduino project folder (with MyProg.ino)

@rem Arduino Type =====================================
@rem
@rem Uno
@rem Set brd=arduino:avr:uno
@rem
@rem Mega
@rem brd=arduino:avr:mega:cpu=atmega2560
@rem
@rem Nano
Set brd=arduino:avr:nano:cpu=atmega328
@rem
@rem Arduino pro mini 
@rem set brd=arduino:avr:pro:cpu=16MHzatmega328
@rem
@rem
rem Arduino software executable =======================
set cmd=C:\Programs\Arduino\arduino.exe
set cmd=C:\Programs\Arduino\arduino_debug.exe
@rem arduino.exe       - GUI, output to stdout, stderr
@rem arduino_debug.exe - output to console

@rem Project folder (and file name) ===================
for /F "delims=\" %%A in ("%0%") do (
  set src=%%~nxA
)

@rem Source path and filename
set afl=C:%~sp0%src%.ino
echo %afl%

@rem Board Type =======================================
@rem Nano
set brd=arduino:avr:nano:cpu=atmega328
@rem Uno
@rem set brd=arduino:avr:uno
@rem Mega
@rem set brd=arduino:avr:mega:cpu=atmega2560
  
rem COM port =========================================
set prt=COM17
rem ==================================================

set bdd=atmega328p
set baud=57600

@rem Temporary files
set tmp=%temp%\Arduino\%src%
if not exist %tmp% mkdir %tmp%
%cmd% --board %brd%  --port %prt% --preserve-temp-files --verify --pref build.path=%tmp% %afl%

@rem arduino --pref build.path=/path/to/sketch/build --verify /path/to/sketch/sketch.ino
@rem used to work with --upload, but now using separate command

set avd=C:\Programs\Arduino\hardware\tools\avr\bin\avrdude
set avc=C:\Programs\Arduino\hardware\tools\avr\etc\avrdude.conf

%avd% -C%avc% -q -p%bdd% -carduino -P%prt% -b%baud% -D -Uflash:w:%tmp%\%src%.ino.hex:i 
@rem -v or -q for verbose or quiet

pause

There's a comment in there that the single build+upload command used to work, but now I'm using a separate command, probably the same issue.

  • in the IDE change the board type to Pro Mini - success! uses 57600 baud.

Using Port : COM17
Using Programmer : arduino
Overriding Baud Rate : 57600

So it looks like the IDE is confused on what's the correct baud rate for a Nano.

Tools -> Processor -> 328p (old bootloader)

As of about a year ago, official nanos ship with a new bootloader that uses 115200 baud (and is based on optiboot). Clones, and older official nanos, use the old bootloader.

@DrAzzy, thanks. Yes, and now I've found a note in https://www.arduino.cc/en/Guide/ArduinoNano.

Did I miss the warning on one of the IDE updates, or does every Nano user go through this?

RichardDL:
does every Nano user go through this?

Judging by the number of posts here about it, yes. Everyone either knows about it from seeing the posts, or trips over it and either figures it out or posts about it.

They kinda bungled the implementation of this change. The new bootloader is smaller - but they didn't set the fuses to take advantage of that (nor adjust the board entry). Any of these would have been better (I'd have picked A or B)
A) Set fuses to use the smaller bootloader section, call the board a nano 3.1 or something, and add a top level entry in board menu for it, with the larger maximum program size allowed by the new bootloader.
B) Set the upload speed to 57600 on the new bootloader and leave fuses alone, so the only way you'd notice a difference is if you were using the WDT reset which hung the old bootloader but works with the new one.
C) As A above, but set upload speed to 57600. This would improve compatibility, but would result in upload failures if the size of the sketch being uploaded was between the old maximum sketch size and the new one and you tried to upload to a board with the old bootloader.

Instead, they combined the two for a worst-of-both-worlds approach which was incompatible with the old bootloader, AND didn't take advantage of the smaller size of the new one.... For a while, they were shipping the new bootloader nanos, when the latest released version of the IDE didn't include support for it, so you had to use board manager to upgrade the AVR board package to work with the new ones. This is why people do things like bootloading all their nano/pro mini boards as Unos (or generic 328p via minicore)

Thanks for the explanation. There are a few interesting things there I hadn't heard of, but I've done some Googling. I have a situation at work that still uses modems, they start at the set baud rate and go down until the other end syncs. I'd have made the loader do that.