4

I am using an Arduino Nano (Clone) which I was programming with the Arduino IDE (Version 1.8.5 on Mac OS X 10.10.5).

Using the Arduino IDE I need to re-plug the Nano before uploading, but after doing this everything works as expected and the sketch is being uploaded successfully.

I then tried to use Platformio core (CLI) and get the well-known not in sync error:

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

As said, this error is well-known, esp. in relation to Arduino clones, and reported several times around the Internet with different solutions.

I just wonder how Arduino IDE is able to upload the code successfully, but Platformio is not since both Arduino IDE and Platformio CLI are just calling avrdude to upload the code.

Remark: Uploading the same code to an Arduino Uno works like a charm with both using Arduino IDE and Platformio.


Updates due to further investigation:

I enabled verbose output for both Arduino IDE and Platformio showing the exact avrdude command executed to upload the built hex-file. I adopted the call to avrdude from Arduino IDE with the path of the compiled Platformio code. This works as expected:

avrdude -v -p atmega328p -c arduino -b 57600 -D -P /dev/cu.usbserial-00000000 -U flash:w:.pioenvs/nano/firmware.hex:i

I then had a look at the command used by Platformio which is quite similar but provides an additional -C for a config-file:

avrdude -v -p atmega328p -C /Users/Albert/.platformio/packages/tool-avrdude/avrdude.conf -c arduino -b 57600 -D -P "/dev/cu.usbserial-00000000" -U flash:w:.pioenvs/nano/firmware.hex:i

Unfortunately, I am not able to run this command from the Terminal due to an error:

avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Users/Albert/.platformio/packages/tool-avrdude/avrdude.conf"
avrdude: syntax error at /Users/Albert/.platformio/packages/tool-avrdude/avrdude.conf:1080
10
  • try to upload to Nano with Uno selected as board
    – Juraj
    Commented Sep 23, 2018 at 20:40
  • 1
    I've tried replicating this issue using a nano clone on mac os 10.12.6 using platformio IDE, and there were no issues. I would try two things: upload a simple blink sketch (or an empty loop) using arduino IDE to make sure the board doesn't try to connect over UART thus interfering with the upload process under platformio; and if this doesn't help, then I would re-flash the bootloader. Also, if platformio is not up to date, it is certainly a good idea to update it to make sure it uses the latest avrdude + config file.
    – ex-punctis
    Commented Sep 23, 2018 at 21:53
  • 1
    @Im_Int: Updated to Arduino 1.8.7 and tryied to reflash boot-loader. Reflashing did not work with Arduino 1.8.7 but with 1.8.5. After that still not able to upload code using Platformio. Tried another Arduino Nano clone: Was able to upload code once with Platformio, but never again. Uploading with Arduino IDE 1.8.7 works, unable to re-flash bootloader to this board as well. There are several discussions around the Internet about the transfer protocol, the use of reset signal on Reset pin (RST) and a capacitor. So this might me a hardware/board-related issue due to cheap Arduino clones... :/
    – albert
    Commented Sep 24, 2018 at 14:41
  • 1
    how do you flash the bootloader?
    – Juraj
    Commented Sep 24, 2018 at 18:52
  • 1
    I used/tried to use an Arduino Uno as ISP since I do not have my original AVR ISP mkII on hand currently
    – albert
    Commented Sep 24, 2018 at 18:55

1 Answer 1

1

Please use board = nanoatmega328new in your platformio.ini

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.