Uploading with stk55v2 not working with attiny84

as of Dec 2023 I am still working on uploading code to an attiny84.
I tried various settings of the ini file:

From the docs:

[env:stk500v2]
platform = atmelavr
framework = arduino
board = attiny84
upload_protocol = custom
upload_flags =
    -C
    ${platformio.packages_dir}/tool-avrdude/avrdude.conf
    -p
    attiny84
    -P
    $UPLOAD_PORT
    -c
    stk500v2
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

Error:
avrdude: error at /Users/ruediheimlicher/.platformio/packages/tool/avrdude/avrdude.conf:422: syntax error
avrdude: error reading system wide configuration file “/Users/ruediheimlicher/.platformio/packages/tool-avrdude/avrdude.conf”

In the acrdude.conf file, lines 416 - 425:

# Overall avrdude defaults; suitable for ~/.config/avrdude/avrdude.rc
#
default_parallel   = "/dev/parport0";
#default_serial     = "/dev/ttyS0";
default_serial     = "/dev/tty.0";
default_spi        = "";
# default_bitclock = 2.5;
default_linuxgpio  = "gpiochip0";
allow_subshells    = no;

I tried to replace the serial port with the real port

/dev/tty.usbserial-AM0190V3

with same error
I also tried
upload_protocol = stk500v2
with same error

The setting

[env:H0_atmega328p]
 platform = atmelavr
 board = atmega328p
 framework = arduino
 upload_protocol = stk500v2

resulted in

RAM:   [====      ]  42.4% (used 217 bytes from 512 bytes)
Flash: [===       ]  29.5% (used 2420 bytes from 8192 bytes)
================================================ [SUCCESS] Took 0.41     seconds ================================================

BUT: NOTHING WAS UPLOADED.

I then again used the upload command used in my old configuration from the Makefile in Xcode.
In Terminal:

avrdude -p t84 -c stk500v2 -P /dev/tty.usbserial-AM0190V3 -U     flash:w:.pio/build/stk500v2/firmware.hex /firmware.hex

This uploaded the hex file without problems.

Working with ESP32- and Teensy-Boards works without problems

I wonder if the other avrdude.conf from Xcode in /usr/local/etc/ could make problems.

macos 12.5 MacBookPro M1

There might be two tool-avrdude versions in /Users/ruediheimlicher/.platformio/packages/, and the binary is from one and the config is from the other? Match the versions if possible.

I have at least 3 avrdude.conf files

  • platformio
  • teensyduino, variant of arduino for working with teensy’s, same as arduino avrdude.conf , at
    /Applications/Teensyduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf
  • Xcode, used in its makefiles, at
    /usr/local/etc/avrdude.conf

Is it possible to merge parts of the Xcode file to the platformio file?

No that’s the wrong approach. It must work with PlatformIO-only usages.

Is it possibly you have avrdude installed globally? You might be needing to use the full path to the executable.

upload_command = ${platformio.packages_dir}/tool-avrdude/avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

Tnks a lot
I am possibly a step further.
avrdude is in /usr/local/bin/
avrdude.conf is in /usr/local/etc
ini file:

[env:stk500v2]
 platform = atmelavr
 board = attiny84
 framework = arduino
 upload_protocol = stk500v2
 upload_port = /dev/tty.usbserial-AM0190V3 
 programmer = stk500v2
 upload_speed = 115200
 upload_flags =
    -C
    /usr/local/etc/avrdude.conf
    -p
     $BOARD_MCU
    -P
     $UPLOAD_PORT
    -b
     $UPLOAD_SPEED
    -c
     stk500v2
    -v
upload_command =  /usr/local/bin/avrdude $UPLOAD_FLAGS  –c stk500v2 –p t84 –P /dev/tty.usbserial-AM0190V3 -U flash:w:$SOURCE:i -v 

 The output begins as usual with the 'User configuration file does not exist' stuff and
        Programmer Type : STK500V2
         Description     : Atmel STK500 Version 2.x firmware
         Programmer Model: STK500
         Hardware Version: 2
         Firmware Version Master : 2.10
         Topcard         : Unknown
          Vtarget         : 5.2 V
         SCK period      : 8.7 us
         Varef           : 2.5 V
         Oscillator      : Off

avrdude: AVR device initialized and ready to accept instructions

and then

Reading | ################################################## | 100% 0.10s
avrdude: Device signature = 0x1e930c (probably t84)
avrdude done.  Thank you.

But: No upload.
What could be the problem?

Strange
Running in terminal from the project folder:

avrdude -p attiny84 -P /dev/tty.usbserial-AM0190V3    -c stk500v2    -U flash:w:.pio/build/stk500v2/firmware.hex 

uploads without problems. Output with -v is

Reading | ################################################## | 100% 0.10s

avrdude: Device signature = 0x1e930c (probably t84)
 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: reading input file ".pio/build/stk500v2/firmware.hex"
 avrdude: input file .pio/build/stk500v2/firmware.hex auto detected as Intel Hex
 avrdude: writing flash (2420 bytes):

 Writing | ################################################## | 100% 1.82s

 avrdude: 2420 bytes of flash written
 avrdude: verifying flash memory against .pio/build/stk500v2/firmware.hex:
 avrdude: input file .pio/build/stk500v2/firmware.hex auto detected as Intel Hex

 Reading | ################################################## | 100% 1.82s

 avrdude: 2420 bytes of flash verified

Are you trying this with the most basic “LED Blink” sketch? Code?

Idea: Does it matter that it is a blank device, without bootloader?

Blinky code:

/*
 * Blink
 */
#include <Arduino.h>
void setup()   
{
  pinMode(4, OUTPUT);
}
 void loop()
{
  digitalWrite(4, HIGH);
   delay(1000);
  digitalWrite(4, LOW);
  delay(1000);
}

output:

avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.10s

Since

the (D)4 pin corresponds to PA6 on the chip. Did you make sure to connect your LED there?

Also, this should work without a bootloader.

LED does not blink.
Creating an arduino sketch with the same code uploads as expected.

What could I do with the json-file?

I have a certain success.
On my monterey machine the upload still stops after reading.

On my other machine with macos Ventura I am now able to upload the code as expected with the exact same ini settings.

ini-file:

platform = atmelavr
board = attiny84
framework = arduino
upload_protocol = stk500v2
upload_port = /dev/tty.usbserial-AM0190V3 
upload_speed = 115200
upload_flags =
    -C
    /opt/homebrew/etc/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -b
    $UPLOAD_SPEED
    -c
    stk500v2
    -v

I wonder why the upload does not run on macos Monterey.

It should really be made to work with the avrdude version that PlatformIO provides, not the system-installed version.

Are you sure that when you point to the absolute paths of the PlatformIO versions (/User/<user>/.platformio/packages/tool-avrdude/bin/avrdude), it cannot be made to work?

What does the package.json inside that folder say the version of avrdude is? There are more available.

I think I got it, for the moment.

running ‘pio run’ from the terminalI I was told that i have multiple PlatformIO Cores.
Following the advices in the troubleshooting page made several things.
After that, I tried with upload_flags without explicit path for avrdude.conf:

[env:stk500v2]
platform = atmelavr
board = attiny84
framework = arduino
upload_protocol = stk500v2
upload_port = /dev/tty.usbserial-AM0190V3 
upload_speed = 115200

upload_flags =
    -C
    avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -b
    $UPLOAD_SPEED
    -c
    stk500v2
    
    -v

I tried compiling my device again and : SUCCESS!
No idea where the multiple PlatformioIO Cores came. Perhaps a misleading experiment with PATH.
I also was able to successful program an attiny85 and an atmega328p. And running pio run from the terminal again gave command not found.
Thanks again for your patience.