Can't upload to Arduino Nano copy

I’m trying to upload a program to an arduino nano copy, in the Arduino IDE I have to select Processor: ATmega328 to upload successfully.
This is my platrom.ini file:

[platformio]
default_envs = nanoatmega328new

[env:nanoatmega328new]
platform = atmelavr
board = nanoatmega328new
framework = arduino
monitor_speed = 115200
upload_port = COM4

How ever platformio failes and gives me this output:

Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...
Use manually specified: COM4
Uploading .pio\build\nanoatmega328new\firmware.hex
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xe6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xe6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xe6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe6
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe6

avrdude done.  Thank you.

When I select ATmega (Old Bootloader) in the Arduino IDE, I get the same output. I was told that it could be possible that this is a problem of the Arduino copy and not platformio.

I also tried board = nanoatmega328 which gave me the same out put as above.

I’ve also have successfully uploaded the same program with board = nanoatmega328 on an other Arduino nano which i think is from a different manufacturer. For this Arduino I also had to choose ATmega (Old Bootloader) in the Arduino IDE.

Any ideas what I could try?

EDIT TO SOLUTION:
I’m not exactly sure but I think burining the bootloader fixed it.

Does your Nano have a CH340 chip as serial converter? Then I’d recommend you install the latest driver from the vendor CH341SER.EXE - 南京沁恒微电子股份有限公司 (blue download button).

And your Arduino Nano has a Atmega328 chip on it and not a 168 one?

You could also try to use different bootloader baud rates, that is the main difference (115200 on new vs 57600). See docs for setting that. you could use board = nanoatmega328 and then add

upload_speed = 115200

with a few different baud rates (e.g. from here).

If none of these baudrates work, then chances are that

  • the bootloader programmed into your Arduino Nano copy is different
  • there is no bootloader programmed
  • the board has a physical defect

Note that in the first two cases, you can indeed try and rescue the board by programming it with an ISP programmer. Basically, you can use another Arduino Uno (I think Nano, too) and flash a special sketch on it that will make that board act like a programmer. Using that programmer, you can reflash the chip directly via the SPI/ISP interface, without going through a bootloader program. If the target chip is not damaged, this will work.

There’s materials available for that here, here, here if you translate it with google, and here. These tutorials use the Arduino IDE, which is perfectly fine to burn the bootloader and is more beginner friendly. But you can also do the same thing using PlatformIO (docs ‘Arduino as ISP’, docs ‘bootloader burning’).

I’ve just been burning the Bootloader but it’s still not working, I already installed the WCH driver and I’m 100% shure that it’s not a 168 because it doesn’t work in the Arduino IDE.

Well it’s not realy a good solution but you can upload the binary after compiling it in PlatformIO with this command in the Terminal:

<Path to arduino IDE home>\hardware\tools\avr/bin/avrdude -C<Path to arduino IDE home>\hardware\tools\avr/etc/avrdude.conf -patmega328p -carduino -P<Port> -b115200 -D -Uflash:w:.pio\build\<env name>\firmware.hex:i

If you try this for your program replace the paths in <> with the ones on your machine.

I got this by copying the command from the Arduino IDE with verbose upload.

Weird, PlatformIO will do the same when you just use board = nanoatmega328new. You can see that in the “Verbose Upload”.

avrdude -v -p atmega328p -C C:\Users\Max.platformio\packages\tool-avrdude\avrdude.conf -c arduino -b 115200 -D -U flash:w:.pio\build\nanoatmega328new\firmware.hex:i

Same programmer (-c arduino) and same baud rate -b 115200). Does that not work in PlatformIO now, too?

I’ve burned it with a Arduino uno, I followed the instructions on this website.

No I meant now that the bootloader is on there and you can flash with the Arduino IDE, then PlatformIO should be able to upload normally too now via the serial bootloader, no?

This is the command that gets executed in PlatformIO:

avrdude -v -p atmega328p -C C:\Users\gian.l\.platformio\packages\tool-avrdude\avrdude.conf -c arduino -b 57600 -D -P "COM4" -U flash:w:.pio\build\nanoatmega328new\firmware.hex:i

(the baudrate is difrent because I changed it in the platform.ini)

Does the basic platformio.ini with

[env:nanoatmega328new]
platform = atmelavr
board = nanoatmega328new
framework = arduino

not work while the same settings work in Arduino IDE? I then get the commandline

avrdude -v -p atmega328p -C C:\Users\Max.platformio\packages\tool-avrdude\avrdude.conf -c arduino -b 115200 -D -U flash:w:.pio\build\nanoatmega328new\firmware.hex:i

for that, which looks the same as what you’ve posted.

I just tried uploading it again and magicly it worked. Maybe it was the bootloader, but i’d guess that some thing with the USB port on my Arduino meight be broken.

1 Like

upload_speed = 115200 solved my problem. thanks!