Odd upload problem jtag2UPDI

Hi, I set up an Arduino Uno as a jtag2UPDI programmer and it works fine using PIO/ VScode on my dev machine i.e uploads code. Brill

My problem is that if I use a different machine and load the project into pio (using github so the files are pulled from github remote), the code upload fails as per the output shown below. All other stuff is the same - in fact the computers are on the same desk, so in order to try thing out, all I did was swap the jtag’ programmer’s USB cable from one to the other.

pio.ini inclded below
As usual probably something I’ve done…
thanks for help

Processing Upload_UPDI (platform: atmelmegaavr; framework: arduino; board: ATmega4809)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/ATmega4809.html
PLATFORM: Atmel megaAVR (1.6.0) > ATmega4809   
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 48KB Flash
PACKAGES:
 - framework-arduino-megaavr-megacorex @ 1.0.10
 - tool-avrdude-megaavr @ 3.60300.220118 (6.3.0)
 - toolchain-atmelavr @ 3.70300.220127 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 14 compatible libraries
Scanning dependencies...
Dependency Graph
|-- AccelStepper @ 1.64.0
|-- SoftwareReset @ 3.0.1
|-- Circular-Linked-List
Building in release mode
Compiling .pio\build\Upload_UPDI\src\ControlBox.cpp.o
Compiling .pio\build\Upload_UPDI\lib72d\AccelStepper\AccelStepper.cpp.o
Compiling .pio\build\Upload_UPDI\lib72d\AccelStepper\MultiStepper.cpp.o
Compiling .pio\build\Upload_UPDI\lib5f0\Circular-Linked-List\linkedList.cpp.o
Compiling .pio\build\Upload_UPDI\lib5f0\Circular-Linked-List\main.cpp.o
Archiving .pio\build\Upload_UPDI\lib72d\libAccelStepper.a
Compiling .pio\build\Upload_UPDI\FrameworkArduino\CDC.cpp.o
Archiving .pio\build\Upload_UPDI\lib5f0\libCircular-Linked-List.a
Compiling .pio\build\Upload_UPDI\FrameworkArduino\Tone.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\UART.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\UART0.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\UART1.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\UART2.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\UART3.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\UNO_compat.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\USBCore.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\WInterrupts.c.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\abi.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\api\Common.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\api\IPAddress.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\api\PluggableUSB.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\api\Print.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\api\RingBuffer.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\api\Stream.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\api\String.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\hooks.c.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\main.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\new.cpp.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\wiring.c.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\wiring_analog.c.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\wiring_digital.c.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\wiring_pulse.S.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\Upload_UPDI\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\Upload_UPDI\libFrameworkArduino.a
Linking .pio\build\Upload_UPDI\firmware.elf
Checking size .pio\build\Upload_UPDI\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  21.1% (used 1294 bytes from 6144 bytes)
Flash: [===       ]  32.0% (used 15730 bytes from 49152 bytes)
Building .pio\build\Upload_UPDI\firmware.hex
Configuring upload protocol...
AVAILABLE: jtag2updi
CURRENT: upload_protocol = jtag2updi
Looking for upload port...
Auto-detected: COM30
Uploading .pio\build\Upload_UPDI\firmware.hex

avrdude: Can't find programmer id "jtag2updi"

Valid programmers are:
  2232HIO          = FT2232H based generic programmer
  4232h            = FT4232H based generic programmer
  arduino          = Arduino
  arduino-ft232r   = Arduino: FT232R connected to ISP
  arduinoisp       = Arduino ISP Programmer
  arduinoisporg    = Arduino ISP Programmer
  atmelice         = Atmel-ICE (ARM/AVR) in JTAG mode
  atmelice_dw      = Atmel-ICE (ARM/AVR) in debugWIRE mode
  atmelice_isp     = Atmel-ICE (ARM/AVR) in ISP mode
  atmelice_pdi     = Atmel-ICE (ARM/AVR) in PDI mode
  avr109           = Atmel AppNote AVR109 Boot Loader
  avr910           = Atmel Low Cost Serial Programmer
  avr911           = Atmel AppNote AVR911 AVROSP
  avrftdi          = FT2232D based generic programmer
  avrisp           = Atmel AVR ISP
  avrisp2          = Atmel AVR ISP mkII
  avrispmkII       = Atmel AVR ISP mkII
  avrispv2         = Atmel AVR ISP V2
  buspirate        = The Bus Pirate
  buspirate_bb     = The Bus Pirate (bitbang interface, supports TPI)
  butterfly        = Atmel Butterfly Development Board
  butterfly_mk     = Mikrokopter.de Butterfly
  bwmega           = BitWizard ftdi_atmega builtin programmer
  C232HM           = FT232H based module from FTDI and Glyn.com.au
  c2n232i          = serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts
  dasa             = serial port banging, reset=rts sck=dtr mosi=txd miso=cts
  dasa3            = serial port banging, reset=!dtr sck=rts mosi=txd miso=cts
  diecimila        = alias for arduino-ft232r
  dragon_dw        = Atmel AVR Dragon in debugWire mode
  dragon_hvsp      = Atmel AVR Dragon in HVSP mode
  dragon_isp       = Atmel AVR Dragon in ISP mode
  dragon_jtag      = Atmel AVR Dragon in JTAG mode
  dragon_pdi       = Atmel AVR Dragon in PDI mode
  dragon_pp        = Atmel AVR Dragon in PP mode
  flip1            = FLIP USB DFU protocol version 1 (doc7618)
  flip2            = FLIP USB DFU protocol version 2 (AVR4023)
  ft232r           = FT232R Synchronous BitBang
  ft245r           = FT245R Synchronous BitBang
  jtag1            = Atmel JTAG ICE (mkI)
  jtag1slow        = Atmel JTAG ICE (mkI)
  jtag2            = Atmel JTAG ICE mkII
  jtag2avr32       = Atmel JTAG ICE mkII im AVR32 mode
  jtag2dw          = Atmel JTAG ICE mkII in debugWire mode
  jtag2fast        = Atmel JTAG ICE mkII
  jtag2isp         = Atmel JTAG ICE mkII in ISP mode
  jtag2pdi         = Atmel JTAG ICE mkII PDI mode
  jtag2slow        = Atmel JTAG ICE mkII
  jtag3            = Atmel AVR JTAGICE3 in JTAG mode
  jtag3dw          = Atmel AVR JTAGICE3 in debugWIRE mode
  jtag3isp         = Atmel AVR JTAGICE3 in ISP mode
  jtag3pdi         = Atmel AVR JTAGICE3 in PDI mode
  jtagkey          = Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2
  jtagmkI          = Atmel JTAG ICE (mkI)
  jtagmkII         = Atmel JTAG ICE mkII
  jtagmkII_avr32   = Atmel JTAG ICE mkII im AVR32 mode
  lm3s811          = Luminary Micro LM3S811 Eval Board (Rev. A)
  mib510           = Crossbow MIB510 programming board
  mkbutterfly      = Mikrokopter.de Butterfly
  nibobee          = NIBObee
  o-link           = O-Link, OpenJTAG from www.100ask.net
  openmoko         = Openmoko debug board (v3)
  pavr             = Jason Kyle's pAVR Serial Programmer
  pickit2          = MicroChip's PICkit2 Programmer
  ponyser          = design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts
  siprog           = Lancos SI-Prog <http://www.lancos.com/siprogsch.html>
  stk500           = Atmel STK500
  stk500hvsp       = Atmel STK500 V2 in high-voltage serial programming mode
  stk500pp         = Atmel STK500 V2 in parallel programming mode
  stk500v1         = Atmel STK500 Version 1.x firmware
  stk500v2         = Atmel STK500 Version 2.x firmware
  stk600           = Atmel STK600
  stk600hvsp       = Atmel STK600 in high-voltage serial programming mode
  stk600pp         = Atmel STK600 in parallel programming mode
  ttl232r          = FTDI TTL232R-5V with ICSP adapter
  tumpa            = TIAO USB Multi-Protocol Adapter
  UM232H           = FT232H based module from FTDI and Glyn.com.au
  uncompatino      = uncompatino with all pairs of pins shorted
  usbasp           = USBasp, http://www.fischl.de/usbasp/
  usbasp-clone     = Any usbasp clone with correct VID/PID
  usbtiny          = USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
  wiring           = Wiring
  xplainedmini     = Atmel AVR XplainedMini in ISP mode
  xplainedmini_dw  = Atmel AVR XplainedMini in debugWIRE mode
  xplainedpro      = Atmel AVR XplainedPro in JTAG mode

*** [upload] Error 1
============================================================================================== [FAILED] Took 15.09 seconds ==============================================================================================
Environment    Status    Duration
-------------  --------  ------------
Upload_UPDI    FAILED    00:00:15.086
========================================================================================= 1 failed, 0 succeeded in 00:00:15.086 =========================================================================================
 *  The terminal process "C:\Users\Paul\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload'" terminated with exit code: 1. 

pio.ini:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = Upload_UPDI

[env]
platform = atmelmegaavr
framework = arduino
board = ATmega4809
board_build.f_cpu = 16000000L
board_hardware.oscillator = internal
board_build.variant = 40pin-standard
build_unflags = 
build_flags = 
monitor_port = COM48
monitor_speed = 19200
monitor_echo = on
lib_extra_dirs = 
	C:\Users\Paul\Documents\PlatformIO\Projects\Development\
lib_deps = 
	waspinator/AccelStepper@^1.61
	qub1750ul/SoftwareReset@^3.0.0
    

[env:Upload_UPDI]
;upload_port = COM24
upload_flags = 
	-C
	$PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
	-p
	$BOARD_MCU
	-c
	jtag2updi
	-P
	COM30
	-b
	115200
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

[env:fuses_bootloader]
extends = env:Upload_UPDI
board_hardware.bod = 2.7v
board_hardware.eesave = yes
board_hardware.uart = no_bootloader
board_hardware.rstpin = reset



This assumes $PROJECT_PACKAGES_DIR/tool-avrdude is the path ot the used avrdude version – there may be multiple tool-avrdude@<version> folders in C:\Users\<user>\.platformio\packages, e.g. one for 6.3 and one for 7.1.

If you did not modify anything inside the packages, I’d simply recommend to delete C:\Users\<user>\.platformio\packages and reupload.

You may also need to explicitly request the other version in the platformio.ini,

; 7.1.0
platform_packages = tool-avrdude@~1.70100.0
; 6.3.0
platform_packages = tool-avrdude@~1.60300.0

Thanks for reply - how do I tell what the used avrdude version is?

I’ve checked both machines and

exists on both.

My goal is to have the same setup on both machines if possible.

Is deleting C:\Users\<user>\.platformio\packages and reuploading the best way to do that?

thanks

I have read the pio documentation on avrdude, but it hasn’t helped with my problem.

I am assuming that the version of avrdude used to effect the code upload is the one specified in this directory:

`$PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf`

So on my dev machine (which uploads successfully using the jtag2UPDI programmer) in a win 10 cmd window as per mage below, I ran a command to check the programmers which avrdude recognises, but as you can see jtag2UPDI isn’t in the list.

So how is my code upload succesful?

Just trying to understand what’s going on so that I can replicate whatever I need in order to upload using jtag2UPDI on a different WIN 10 machine.
thanks for help

even more strange, as when searching avrdude.conf, jtag2UPDI is listed in there as a programmer.

# JTAG2UPDI
# https://github.com/ElTangas/jtag2updi

programmer
    id                     = "jtag2updi";
    desc                   = "JTAGv2 to UPDI bridge";
    type                   = "jtagmkii_updi";
    prog_modes             = PM_UPDI;
    connection_type        = serial;
    baudrate               = 115200;
    hvupdi_support         = 1;
;

I’ll check my other machine and post back if I can’t sort it.
thanks.

HI, I deleted the packages directory, opened my project and let pio install stuff.

I then installed avrdude 7.2 into the packages directory in a folder which I created named tool-avrdude, by unpacking the avrdude zip into it.

my PIO.ini is the same as posted previously

i now get the following which I am unable to resolve, any help much appreciated:

task: C:\Users\Paul\.platformio\penv\Scripts\platformio.exe run --target upload

Processing Upload_UPDI (platform: atmelmegaavr; framework: arduino; board: ATmega4809)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/ATmega4809.html
PLATFORM: Atmel megaAVR (1.6.0) > ATmega4809    
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 48KB Flash  
PACKAGES:
 - framework-arduino-megaavr-megacorex @ 1.0.10  
 - tool-avrdude-megaavr @ 3.60300.220118 (6.3.0)
 - toolchain-atmelavr @ 3.70300.220127 (7.3.0)  
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 14 compatible libraries
Scanning dependencies...
Dependency Graph
|-- AccelStepper @ 1.64.0
|-- SoftwareReset @ 3.0.1
|-- Circular-Linked-List
Building in release mode
Checking size .pio\build\Upload_UPDI\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  21.1% (used 1294 bytes from 6144 bytes)
Flash: [===       ]  32.0% (used 15730 bytes from 49152 bytes)
Configuring upload protocol...
AVAILABLE: jtag2updi
CURRENT: upload_protocol = jtag2updi
Looking for upload port...
Auto-detected: COM30
Uploading .pio\build\Upload_UPDI\firmware.hex
avrdude: error at C:\Users\Paul\.platformio\packages/tool-avrdude/avrdude.conf:421: syntax error
avrdude: error reading system wide configuration file "C:\Users\Paul\.platformio\packages/tool-avrdude/avrdude.conf"
*** [upload] Error 1
============================================================================================== [FAILED] Took 2.20 seconds ==============================================================================================

just trying to build the avrdude command in a windows command prompt.

I searched the pio docs, but couldn’t find where $SOURCE points.
[edit] - I found it:
C:\Users.…\Projects\Live\Control-Box.pio\build\Upload_UPDI

so far I’ve got this to work, without avrdude complaining about the avrdude.conf file. But it does of course complain about $SOURCE - no such file or directory.

C:\Users\Paul\.platformio\packages\tool-avrdude>avrdude -C avrdude.conf -c jtag2updi -P COM30 -b 115200 -U flash:w:$SOURCE:i -p ATmega4809

ok, so from a win 10 command prompt this works:

C:\Users\Paul\.platformio\packages\tool-avrdude>avrdude -C avrdude.conf -c jtag2updi -P COM30 -b 115200 -U flash:w:C:\Users\Paul\Documents\PlatformIO\Projects\Live\controlBox\.pio\build\Upload_UPDI\firmware.hex:i -p ATmega4809
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9651 (probably m4809)
avrdude: Note: flash memory has been specified, an erase cycle will be performed.
         To disable this feature, specify the -D option.
avrdude: erasing chip

avrdude: processing -U flash:w:C:\Users\Paul\Documents\PlatformIO\Projects\Live\controlBox\.pio\build\Upload_UPDI\firmware.hex:i
avrdude: reading input file C:\Users\Paul\Documents\PlatformIO\Projects\Live\controlBox\.pio\build\Upload_UPDI\firmware.hex for flash
         with 15730 bytes in 1 section within [0, 0x3d71]
         using 123 pages and 14 pad bytes
avrdude: writing 15730 bytes flash ...
Writing | ################################################## | 100% 3.32 s
avrdude: 15730 bytes of flash written
avrdude: verifying flash memory against C:\Users\Paul\Documents\PlatformIO\Projects\Live\controlBox\.pio\build\Upload_UPDI\firmware.hex
Reading | ################################################## | 100% 3.03 s
avrdude: 15730 bytes of flash verified

avrdude done.  Thank you.

But PIO won’t upload, showing the syntax error I’ve posted.
I constructed the command prompt line which works from the items specified in the upload_flags section of pio.ini

any help much appreciated.