PlatformIO Community

Terminal works, but upload doesn't

I am seeing a strange bug, where the serial connection to an AVR processor

  • works for the terminal,
  • works for avrdude called from the command line,
  • does not work for avrdude called via pio run.

I have PlatformIO, version 4.3.4 on a Windows 10 machine, using Visual Studio Code
The microcontroller is an ATmega324PA on a custom board, with Optiboot 8.0 set for 57600 Baud

Running the Serial Monitor works:

Executing task: C:\Users\bernd.platformio\penv\Scripts\platformio.exe device monitor <
— Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
— More details at http://bit.ly/pio-monitor-filters
— Miniterm on COM10 57600,8,N,1 —
… some output from my AVR program …

Running the avrdude version that comes with Arduino from the command line works:

“C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe” -C “C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf” -p atmega324pa -P COM10 -b 57600 -c arduino -v -Uflash:w:.pio\build\avr\firmware.elf
avrdude.exe: Version 6.3-20190619
Copyright © 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright © 2007-2014 Joerg Wunsch
System wide configuration file is “C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf”
Using Port : COM10
Using Programmer : arduino
Overriding Baud Rate : 57600
AVR Part : ATmega324PA

avrdude.exe: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.05s
avrdude.exe: Device signature = 0x1e9511 (probably m324pa)

avrdude.exe: writing flash (23750 bytes):
Writing | ################################################## | 100% 18.58s

Reading | ################################################## | 100% 20.18s
avrdude.exe: verifying …
avrdude.exe: 23750 bytes of flash verified

But PlatformIO:Upload does not work

Looking for upload port...
Use manually specified: COM10
Uploading .pio\build\avr\firmware.hex
avrdude: Version 6.3, compiled on Sep 12 2016 at 17:24:16
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch
             System wide configuration file is "C:\Users\myname\.platformio\packages\tool-avrdude\avrdude.conf"
             Using Port                    : COM10
             Using Programmer              : arduino
             Overriding Baud Rate          : 57600
avrdude: ser_open(): can't open device "\\.\COM10": Element not found.

Any explanations?

platformio.ini looks like this (excerpt)

board_build.variant = standard
board_build.mcu = atmega324pa
board_build.f_cpu = 16000000L
monitor_port = COM10
monitor_speed = 57600
upload_port = COM10
upload_speed = 57600

The COM10 serial link is through a HC-06 Bluetooth module, with a simple circuit that mimics the DTR signal to create the processor when the connection is opened

What avrdude invocation command is shown when you execute “Verbose Upload” (pio run -t upload -v)?

avrdude -v -p atmega324pa -C C:\Users\myname\.platformio\packages\tool-avrdude\avrdude.conf -c arduino -b 57600 -D -P "COM10" -U flash:w:.pio\build\avr\firmware.hex:i

By the way: if I run this command directly in a regular Windows shell, it works, i.e. the upload to the AVR completes without error:
c:\Users\myname\.platformio\packages\tool-avrdude\avrdude.exe -p atmega324pa -C C:\Users\myname\.platformio\packages\tool-avrdude\avrdude.conf -c arduino -b 57600 -D -P "COM10" -U flash:w:.pio\build\avr\firmware.hex:i