Locating avrdude

Hi, I have made some progress on using a MicroUPDI as an avr4809 programmer and I’ve been advised by the author to download the latest versions of megacorex and avrdude.

I’ve had a look through the PIO docs for mention of avrdude, but can’t find how PIO locates the program. Unfortunately there are multiple installs of avrdude on my machine and it occurred to me that I need to a) to get rid of multiple installs, b) Find out which install PIO is using

So as a first step on my Win 10 m/c, I removed all environment vars with references to arduino folders and winavr, and restarted the m/c. However PIO still finds avrdude when I try a code upload. Does it have it’s own copy of avrdude? Where would that be located?

Regarding downloading the latest version of megacorex, do I need to put that in a particular place?

thanks for help.

If you delete PlatformIO’s version of avrdude it will detect it as a missing package and redownload and reextract it. That’s what it’s supposed to do.

PlatformIO will always tell you what package at which version it uses. For example, when I create a ATmega4809 project and click “Upload”, the log shows

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
...

And right there at

tool-avrdude-megaavr @ 3.60300.220118 (6.3.0)

is the name and exact version (which will be found in the package.json). The package itself will be located by the displayed name at C:\Users\<user>\.platformio\packages.

If there multiple versions of that package installed, PlatformIO will choose a package@version name for the folder so that it’s identifyable, next to the version contained in the package.json of course.

The same principle holds for framework-arduino-megaavr-megacorex.

Also note that per documentation, you can always redirect the packages to some other folder path per-project, e.g.

platform_packages =
   tool-avrdude-megaavr@symlink://C:/Users/Max/Downloads/MyGreatAVRDUDE/

note that the target folder then needs to have a package.json present, which can e.g. be copied from the old tool-avrdude-megaavr folder in the location mentioned before. Then you don’t have to modify any PlatformIO packages on disc, you just redirect them per-project.

ok thanks for comprehensive reply.

As I have been advised by mcuDude to use avrdude 7.1 as it works better with MicroUPDI, how can I get PIO to use the 7.1 version?

Also, does PIO have a rule of some kind regarding versions i.e. why is my PIO system using avrdude 6.3 when 7.1 is avalable?

thanks.

Actually, all I was about to write has been obseleted.

PlatformIO already is using the latest AVRDude 7.1 for MegaCoreX uploads.

So you just have to update your platform version. One way to do that (there’s also one with the PIO Home GUI), open CLIpio pkg update -g -p atmelmegaavr. Then reupload.

thanks, I’ve just done the package update. Is something similar required to keep megacorex at the latest version?

Thanks for your help, when I now try to upload using the MicroUPDI, I get the errors below. I’m guessing this is something to do with the programmer’s firmware is it best if I post at MicroUPDI?

pio.ini included below also

output from upload:

Executing 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.8.0) > ATmega4809
HARDWARE: ATMEGA4809 20MHz, 6KB RAM, 48KB Flash
PACKAGES:
 - framework-arduino-megaavr-megacorex @ 1.1.1
 - tool-avrdude @ 1.70100.0 (7.1.0)
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 25 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:   [==        ]  20.8% (used 1278 bytes from 6144 bytes)
Flash: [===       ]  31.1% (used 15283 bytes from 49152 bytes)
Configuring upload protocol...
AVAILABLE: xplainedmini_updi
CURRENT: upload_protocol = xplainedmini_updi
Looking for upload port...
Uploading .pio\build\Upload_UPDI\firmware.hex
avrdude warning: ATmega329's flash writepage misses a necessary address bit a13 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:5954]
avrdude warning: ATmega649's flash writepage misses a necessary address bit a14 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:6180]
avrdude warning: AT90PWM2's eeprom writepage misses a necessary address bit a8 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:9377]
avrdude warning: ATtiny44's eeprom writepage misses a necessary address bit a7 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:11235]
avrdude warning: ATtiny84's eeprom writepage misses a necessary address bit a8 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:11419]
avrdude warning: a4 would normally be expected to be a5 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:11704]
avrdude warning: a3 would normally be expected to be a4 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:11704]
avrdude warning: a2 would normally be expected to be a3 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:11704]
avrdude warning: a1 would normally be expected to be a2 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:11704]
avrdude warning: a0 would normally be expected to be a1 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:11704]
avrdude warning: too few opcode bits in instruction [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:11704]
avrdude warning: ATtiny43u's eeprom read misses a necessary address bit a5 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:11723]
avrdude warning: ATmega32U4's eeprom writepage misses a necessary address bit a2 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:11909]
avrdude warning: AT90USB1286's eeprom writepage misses a necessary address bit a11 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:12304]
avrdude warning: ATtiny1634's flash writepage misses a necessary address bit a5 [C:\Users\Paul\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:15060]
avrdude error: no response from device
avrdude error: SET_IDLE failed
avrdude error: wrote -138 out of 64 bytes, err = Unknown error
avrdude error: wrote -138 out of 64 bytes, err = Unknown error
avrdude error: unable to open programmer xplainedmini_updi on port usb

avrdude done.  Thank you.

*** [upload] Error 1
===================================================================================== [FAILED] Took 23.56 seconds =====================================================================================
Environment    Status    Duration
-------------  --------  ------------
Upload_UPDI    FAILED    00:00:23.563
================================================================================ 1 failed, 0 succeeded in 00:00:23.563 ========

pio.ini :

; PlatformIO template configuration file for MegaCoreX
; https://github.com/MCUdude/MegaCoreX/
;
;   Build options: build flags, source filter
;   Hardware options: oscillator type, BOD, UART number, EEPROM retain
;   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
; https://github.com/MCUdude/MegaCoreX/blob/master/PlatformIO.md
; https://docs.platformio.org/page/projectconf.html
; https://docs.platformio.org/en/latest/platforms/atmelmegaavr.html

[platformio]
; Default build target
default_envs = Upload_UPDI

; Parameters used for all environments
[env]
platform = atmelmegaavr
framework = arduino

; Chip in use
board = ATmega4809
; Clock frequency in [Hz]
board_build.f_cpu = 20000000L
; Oscillator type (internal or external)
board_hardware.oscillator = internal
; Arduino pinout variant
board_build.variant = 40pin-standard

; Unflag build flags
build_unflags =
; Extra build flags
build_flags =

; Monitor port is auto detected. Override here
;monitor_port =
monitor_speed = 9600
lib_extra_dirs = 
	C:\Users\Paul\Documents\PlatformIO\Projects\Development\
lib_deps = 
	waspinator/AccelStepper@^1.61
	qub1750ul/SoftwareReset@^3.0.0    

; Run the following command to upload with this environment
; pio run -t upload
[env:Upload_UPDI]
; Upload protocol for UPDI upload
upload_protocol = xplainedmini_updi
upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude-megaavr/avrdude.conf
    -p
    $BOARD_MCU
    -c
    xplainedmini_updi
    -P
	usb
    -b
	115200
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

; Run the following command to upload with this environment
; pio run -e Upload_UART -t upload
;[env:Upload_UART]
; Upload protocol for serial uploads (using Optiboot)
;upload_protocol = arduino
;upload_port = /dev/cu.usbserial*
;upload_flags =


; run the following command to set fuses
; pio run -e fuses_bootloader -t fuses
; run the following command to set fuses + burn bootloader
; pio run -e fuses_bootloader -t bootloader
[env:fuses_bootloader]
; Inherit upload settings from the Upload_UPDI environment
extends = env:Upload_UPDI

; Hardware settings
board_hardware.bod = 2.7v
board_hardware.eesave = yes
board_hardware.uart = no_bootloader
board_hardware.rstpin = reset


That doesn’t look right at all, why would it bel load the avrdude.conf from the tool-avrdude-megaavr package if it’s now using the tool-avrdude package version 7.1? Did you point it to that config file in the platformio.ini? If yes, that needs to be adapted to tool-avrdude.

all I did was execute the command above. The pio.ini is a template from PIO docs with some extra upload flags added as per post.

How can I point pio at the correct avrdude.conf ?
edit:
sorry just seen the item in the pio.ini I will fix it - please disregard this post and thanks for help.
end edit
thanks

ok so I have re pointed the upload flag to

upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf

and now get this output whn trying to upload:

Executing 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.8.0) > ATmega4809   
HARDWARE: ATMEGA4809 20MHz, 6KB RAM, 48KB Flash
PACKAGES:
 - framework-arduino-megaavr-megacorex @ 1.1.1 
 - tool-avrdude @ 1.70100.0 (7.1.0)
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0) 
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 25 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:   [==        ]  20.8% (used 1278 bytes from 6144 bytes)
Flash: [===       ]  31.1% (used 15283 bytes from 49152 bytes)
Configuring upload protocol...
AVAILABLE: xplainedmini_updi
CURRENT: upload_protocol = xplainedmini_updi
Looking for upload port...
Uploading .pio\build\Upload_UPDI\firmware.hex
avrdude error: no response from device
avrdude error: SET_IDLE failed
avrdude error: wrote -138 out of 64 bytes, err = Unknown error
avrdude error: wrote -138 out of 64 bytes, err = Unknown error
avrdude error: unable to open programmer xplainedmini_updi on port usb

avrdude done.  Thank you.

*** [upload] Error 1
===================================================================================== [FAILED] Took 23.71 seconds =====================================================================================
Environment    Status    Duration
-------------  --------  ------------
Upload_UPDI    FAILED    00:00:23.710
================================================================================ 1 failed, 0 succeeded in 00:00:23.710 ===================

pio. ini :

; PlatformIO template configuration file for MegaCoreX
; https://github.com/MCUdude/MegaCoreX/
;
;   Build options: build flags, source filter
;   Hardware options: oscillator type, BOD, UART number, EEPROM retain
;   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
; https://github.com/MCUdude/MegaCoreX/blob/master/PlatformIO.md
; https://docs.platformio.org/page/projectconf.html
; https://docs.platformio.org/en/latest/platforms/atmelmegaavr.html

[platformio]
; Default build target
default_envs = Upload_UPDI

; Parameters used for all environments
[env]
platform = atmelmegaavr
framework = arduino

; Chip in use
board = ATmega4809
; Clock frequency in [Hz]
board_build.f_cpu = 20000000L
; Oscillator type (internal or external)
board_hardware.oscillator = internal
; Arduino pinout variant
board_build.variant = 40pin-standard

; Unflag build flags
build_unflags =
; Extra build flags
build_flags =

; Monitor port is auto detected. Override here
;monitor_port =
monitor_speed = 9600
lib_extra_dirs = 
	C:\Users\Paul\Documents\PlatformIO\Projects\Development\
lib_deps = 
	waspinator/AccelStepper@^1.61
	qub1750ul/SoftwareReset@^3.0.0    

; Run the following command to upload with this environment
; pio run -t upload
[env:Upload_UPDI]
; Upload protocol for UPDI upload
upload_protocol = xplainedmini_updi
upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -c
    xplainedmini_updi
    -P
	usb
    -b
	115200
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

; Run the following command to upload with this environment
; pio run -e Upload_UART -t upload
;[env:Upload_UART]
; Upload protocol for serial uploads (using Optiboot)
;upload_protocol = arduino
;upload_port = /dev/cu.usbserial*
;upload_flags =


; run the following command to set fuses
; pio run -e fuses_bootloader -t fuses
; run the following command to set fuses + burn bootloader
; pio run -e fuses_bootloader -t bootloader
[env:fuses_bootloader]
; Inherit upload settings from the Upload_UPDI environment
extends = env:Upload_UPDI

; Hardware settings
board_hardware.bod = 2.7v
board_hardware.eesave = yes
board_hardware.uart = no_bootloader
board_hardware.rstpin = reset