Pyupdi fails when started from VSCode


There’s a strange issue here. I’ve previously used Atmel Studio and successfully uploaded my applications to a bare ATtiny1614 chip using pyupdi and a customised serial cable with the added resistor. Now I’m trying out VSCode+PlatformIO. I could compile a simple test program. But deploying it to the chip fails.

When I run pyupdi directly as I’ve done in the past, everything works. My program is uploaded and then starts running with blinking LEDs.

When I start this through the button in VSCode, with the appropriate configuration from the docs, all sorts of errors occur.

  • Sometimes, Python can’t find the “intelhex” module, but I’ve just installed it and this is never an issue when running pyupdi from a Windows commandline.
  • Sometimes, the serial communication starts and the chip is reset, but then the tx/rx lights remain constantly on and nothing happens anymore. Nothing is uploaded, the process never completes, while the current chip program keeps running (blinking LEDs).

What is VSCode/PlatformIO doing differently than just starting a new process?

Here’s my config:

platform = atmelmegaavr
board = ATtiny1614
;framework = arduino

; default baudrate: 115200
; maximum working baudrate: 230400
upload_speed = 230400
upload_flags =
upload_command = python C:\Source\Elektronik\pyupdi\ $UPLOAD_FLAGS -f $SOURCE

The used COM port is correct. It’s the same I use in my batch file.

The -p parameter is one that I added to pyupdi to show me the upload progress. It still fails when I leave it away.

This batch file works flawlessly every time:

@echo off
cd /d "%~dp0"

:: default baudrate: 115200
:: maximum working baudrate: 230400
python C:\Source\Elektronik\pyupdi\ -d tiny1614 -c COM7 -b 230400 -f .pio\build\ATtiny1614\firmware.hex -p

Should I just keep using my batch file like I did with Atmel Studio (which was entirely unable to integrate it anyway) or is there a chance that I can integrate pyupdi into VSCode here?

  • I’m running on Windows 10.
  • Python 3.9.6 and pyupdi are probably a bit outdated but working nonetheless (outside VSCode). My VSCode can handle Python scripts (in a different workspace) but that’s probably irrelevant here.
  • VSCode 1.70.2
  • PlatformIO IDE extension 2.5.2 (just installed today)