Solved: Upload reports success but fails: cannot run quickstart/Blink

Hi, brand new PlatformIO user. I have have just installed (by adding the package to existing Atom 7.2 install on Mac OS X 10.11.3). I have been following the Quick Start, and have created blink.cpp by copy-pasting from the docs. I am trying to install to an Arduino Nano clone. The clone drivers have been previously installed and it DOES work with the Arduino IDE. I am connecting it via the built-in USB, and shows up in /dev as ‘cu.wch ch341 USB=>RS232 1430’, which I have aliased to /dev/cu.wch; In the Arduino IDE I can select “Arduino Nano”, “Atmega 328”, and “/dev/cu.wch”, and I am able to upload sketches to the board. The Nano is plugged in to an empty breadboard to hold it in place, and is being powered by the USB connection. No other connections are present.

When I try to upload using PlatformIO, I get no error messages. I can see the RX light on the Pro blinking, but the old sketch runs once the upload is complete. Top aid in testing, I have done the following:

  1. Using Arduino IDE, I loaded the built-in example “Blink” Sketch. I have changed the timing and uploaded to the board successfully several times, to prove that that is working. I finished by setting the timing to 2000 ms on, 500 ms off, and uploaded the sketch. I then quit the Arduino IDE.

  2. Using PlatformIO, I have built and uploaded the “blink” demo from the Getting Started guide, with updated timing (500 ms on, 500 ms off), so there would be no doubt if the new sketch was running. I did note that while the RX light blinks during upload, the TX light never blinks. Pressing Reset after upload also results in the old sketch continuing to run.

At this point I’m convinced that my Nano clone is working, the Arduino IDE can upload sketches to it, and PlatformIO cannot. I’ve captured the build and upload logs:

Build Log:

[Sun Apr 24 19:01:26 2016] Processing nanoatmega328 (platform: atmelavr, board: nanoatmega328, framework: arduino)
avr-g++ -o .pioenvs/nanoatmega328/src/main.o -c -fno-exceptions -fno-threadsafe-statics -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_
CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO_AVR_NANO -DARDUINO=10608 -DPLATFORMIO=020806 -I.pioenvs/nanoatmega328/FrameworkArduino -I.pioenvs/nanoatmega328/FrameworkArduino
Variant src/main.cpp
avr-g++ -o .pioenvs/nanoatmega328/firmware.elf -Os -mmcu=atmega328p -Wl,--gc-sections,--relax .pioenvs/nanoatmega328/src/main.o -L/Users/jclark/.platformio/packages/ldscri
pts -L.pioenvs/nanoatmega328 -Wl,--start-group .pioenvs/nanoatmega328/libFrameworkArduinoVariant.a .pioenvs/nanoatmega328/libFrameworkArduino.a -lm -Wl,--end-group
avr-objcopy -O ihex -R .eeprom .pioenvs/nanoatmega328/firmware.elf .pioenvs/nanoatmega328/firmware.hex

"avr-size" --mcu=atmega328p -C -d .pioenvs/nanoatmega328/firmware.elf
AVR Memory Usage
Device: atmega328p
Program:    1034 bytes (3.2% Full)
(.text + .data + .bootloader)
Data:          9 bytes (0.4% Full)
(.data + .bss + .noinit)
========================= [SUCCESS] Took 0.45 seconds =========================

Upload log:

[Sun Apr 24 19:05:20 2016] Processing nanoatmega328 (platform: atmelavr, board: nanoatmega328, framework: arduino)
BeforeUpload(["upload"], [".pioenvs/nanoatmega328/firmware.hex"])
Auto-detected UPLOAD_PORT/DISK: /dev/cu.wch ch341 USB=>RS232 1430
"/Users/jclark/.platformio/packages/tool-avrdude/avrdude" -v -p atmega328p -C "/Users/jclark/.platformio/packages/tool-avrdude/avrdude.conf" -c arduino -b 57600 -P /dev/cu.wch ch341
USB=>RS232 1430 -D -U flash:w:.pioenvs/nanoatmega328/firmware.hex:i
Copyright (c) 2000-2005 Brian Dean,

avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24
System wide configuration file is "/Users/jclark/.platformio/packages/tool-avrdude/avrdude.conf"
Copyright (c) 2007-2009 Joerg Wunsch
User configuration file is "/Users/jclark/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port                    : /dev/cu.wch
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.02s

avrdude: Device signature = 0x1e950f

avrdude done.  Thank you.
========================= [SUCCESS] Took 4.04 seconds =========================

Unfortunately, I don’t know enough about avrdude to know if the output looks correct, but I could find no obvious errors, and the command line makes sense after looking at the avrdude docs. I’m not sure what to check next.

Solved. Upon reviewing everything after some time away, I discovered that the “auto-detected UPLOAD_PORT” in the upload log was grabbing the full port name (containing spaces) and not my symlink, and that it was being passed to avrdude's -P option without being quoted. I updated my platformio.ini to specify the upload port directly, using the symlink:

platform = atmelavr
framework = arduino
board = nanoatmega328
# new line: specify symlink for port.
upload_port = /dev/cu.wch

This is a bug. I’ve just fixed it in f7be8ad666.

Please remove symbolic link and test it with the latest Redirecting...