Issue migrating from Windows to Ubuntu - ATtiny85 - avrdue syntax error

I am migrating from Windows 10 to Ubuntu (I did a test migration on two laptops with no problems).

I can program UPDI devices (eg ATtiny1604) with the pymcuprog script and modified serial card (proves I successfully installed PlatformIO as Visual Studio extension, and successfully loaded the python script as a local instance).

I can program an Aurduino Nano with no problems but I get an avrdude syntax error when I try to program an ATtiny85 either using Arduino as ISP or a USBASP programmer (yes, I’ve installed 99-platformio-udev.rules file to support this programmer).

I’ve checked that the avrdude.conf file is where it expects it to be.

Please can you suggest what I may check / change.
Here’s all the details…
Source

#include <Arduino.h>

// put function declarations here:
int myFunction(int, int);

void setup() {
  // put your setup code here, to run once:
  int result = myFunction(2, 3);
}

void loop() {
  // put your main code here, to run repeatedly:
}

// put function definitions here:
int myFunction(int x, int y) {
  return x + y;
}

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

[env:attiny85]
platform = atmelavr
board = attiny85
framework = arduino

; uploader tool selection - use one block but comment out the other

; device is USBASP V2.0 with updated firmware
; upload_protocol = custom
; upload_port = usb
; upload_flags =
;     -C
;     ; use "tool-avrdude-megaavr" for the atmelmegaavr platform
;     ${platformio.packages_dir}/tool-avrdude/avrdude.conf
;     -p
;     $BOARD_MCU
;     -P
;     $UPLOAD_PORT
;     -c
;     usbasp
; upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i


; device is Arduino as ISP
upload_protocol = custom
upload_port = /dev/ttyACM0
upload_speed = 19200
; monitor_port = /dev/ttyACM0
; monitor_speed = 57600
upload_flags =
    -C
    ; use "tool-avrdude-megaavr" for the atmelmegaavr platform
    ${platformio.packages_dir}/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -b
    $UPLOAD_SPEED
    -c
    stk500v1
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

The error message…

Executing task in folder ATtiny85BareMinimum: platformio run --target upload 

Processing attiny85 (platform: atmelavr; board: attiny85; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/attiny85.html
PLATFORM: Atmel AVR (5.1.0) > Generic ATtiny85
HARDWARE: ATTINY85 8MHz, 512B RAM, 8KB Flash
DEBUG: Current (simavr) External (simavr)
PACKAGES: 
 - framework-arduino-avr-attiny @ 1.5.2 
 - tool-avrdude @ 1.60300.200527 (6.3.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 9 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio/build/attiny85/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   1.8% (used 9 bytes from 512 bytes)
Flash: [          ]   3.0% (used 248 bytes from 8192 bytes)
Configuring upload protocol...
AVAILABLE: custom
CURRENT: upload_protocol = custom
Uploading .pio/build/attiny85/firmware.hex
avrdude: error at /home/peter/.platformio/packages/tool-avrdude/avrdude.conf:402: syntax error
avrdude: error reading system wide configuration file "/home/peter/.platformio/packages/tool-avrdude/avrdude.conf"
*** [upload] Error 1

A look at the config file location…

peter@XPS-8700:~$ cd /home/peter/.platformio/packages/tool-avrdude/
peter@XPS-8700:~/.platformio/packages/tool-avrdude$ ls
avrdude  avrdude.conf  package.json
peter@XPS-8700:~/.platformio/packages/tool-avrdude$

If I rename the file, I get the following error message (I was hoping the file would be re-created in case it was some how mal-formed)…

avrdude: can't open config file "/home/peter/.platformio/packages/tool-avrdude/avrdude.conf": No such file or directory
avrdude: error reading system wide configuration file "/home/peter/.platformio/packages/tool-avrdude/avrdude.conf"
*** [upload] Error 1

Could it be a privileges thing - how to check?

The avrdue.conf file is too large to paste into this topic but I could copy out a section if directed.

Looking in the config file at line 402, I can see…

# Overall avrdude defaults; suitable for ~/.config/avrdude/avrdude.rc
#
default_parallel   = "/dev/parport0";
default_serial     = "/dev/ttyS0";
default_spi        = "";
# default_bitclock = 2.5;

Line 402 is the default_spi setting. What should this be?

Thanks

avrdude: error at /home/peter/.platformio/packages/tool-avrdude/avrdude.conf:402: syntax error

Looks like a syntax error at line 402 in your conf file.

However, when I was uploading to ATtiny85 some ages ago, I only had to put upload_protocol = usbtiny and not bother with all the custom command stuff.

I used a usbtiny programmer, not a usbasp, though.

HTH

Cheers,
Norm.

@normandunbar - thanks for the pointer - I’ve edited the original post to include what’s in my config file at line 402 - does this shed any light on my issue?

I fired up the laptop where I did my test migration - sadly this has the same file contents as my problem installation.

I’ll try swapping out the complete file for the one on the laptop instance bu this is going to take a while - (I don’t think it’s a corruption in my file at line 402 - I think 402 is an error code)

Do

ls ~/.platformio/packages

There may be multiple tool-avrdude folders at different versions, who cannot interpret the config file from the other version.

Hi Max
Thanks for picking up this thread.
(Incidentally I tried to use a copy of the config file from the other laptop - that failed in the same way.)
Here’s the output from the ls command you suggested…

peter@XPS-8700:~/Documents/PlatformIO/Projects/ATtiny85BareMinimum$ ls ~/.platformio/packages
contrib-piohome        framework-arduino-avr-attiny            tool-avrdude                 toolchain-atmelavr                 tool-scons
framework-arduino-avr  framework-arduino-megaavr-megatinycore  tool-avrdude@1.60300.200527  toolchain-atmelavr@1.70300.191015
peter@XPS-8700:~/Documents/PlatformIO/Projects/ATtiny85BareMinimum$ 

Does this help shed any light?

Regards

Yes, as expected, two versions.

The real fundamental problem is when documentation tells people to use ${platformio.packages_dir}/tool-avrdude/avrdude.conf, that is neglecting the actually used tool-avrdude package version. It’s a mess. PlatformIO has no way of saying here "go into the package directory for the tool-avrdude package that is used in this project.

I suggest you can fix that for your system by:

  1. using the right avrdude path
  2. trying to not have to give a config file path by cleverly using upload_speed and upload_protocol values.

Way 1:

[env:attiny85]
platform = atmelavr
board = attiny85
framework = arduino

; uploader tool selection - use one block but comment out the other

; device is USBASP V2.0 with updated firmware
; upload_protocol = custom
; upload_port = usb
; upload_flags =
;     -C
;     ; use "tool-avrdude-megaavr" for the atmelmegaavr platform
;     ${platformio.packages_dir}/tool-avrdude@1.60300.200527/avrdude.conf
;     -p
;     $BOARD_MCU
;     -P
;     $UPLOAD_PORT
;     -c
;     usbasp
; upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i


; device is Arduino as ISP
upload_protocol = custom
upload_port = /dev/ttyACM0
upload_speed = 19200
; monitor_port = /dev/ttyACM0
; monitor_speed = 57600
upload_flags =
    -C
    ; use "tool-avrdude-megaavr" for the atmelmegaavr platform
    ${platformio.packages_dir}/tool-avrdude@1.60300.200527/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -b
    $UPLOAD_SPEED
    -c
    stk500v1
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

Way 2:

[env:attiny85]
platform = atmelavr
board = attiny85
framework = arduino

; uploader tool selection - use one block but comment out the other
; device is USBASP V2.0 with updated firmware
; upload_protocol = usbasp
; upload_port = usb


; device is Arduino as ISP
upload_protocol = stk500v1
upload_port = /dev/ttyACM0
upload_speed = 19200
; monitor_port = /dev/ttyACM0
; monitor_speed = 57600
1 Like

Hi Max
Many thanks for speedy response - seems to make sense.
I’ll try out both tomorrow…

Option 1 worked for me both using Arduino as ISP and my USBASP.
How are you able to check what instance of tool-avrdue to use?

Option 2 seems to have tripped over another issue. See my platforio.ini below and the error message. It seems not needing to specify a path to the tool-avrdude has it looking for the home directory of someone (jenkins) who has no home directory on my machine - thoughts?

; 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

[env:attiny85]
platform = atmelavr
board = attiny85
framework = arduino

; uploader tool selection - use one block but comment out the other

; device is USBASP V2.0 with updated firmware
; upload_protocol = custom
; upload_port = usb
; upload_flags =
;     -C
;     ; use "tool-avrdude-megaavr" for the atmelmegaavr platform
;     ; ${platformio.packages_dir}/tool-avrdude/avrdude.conf
;     ${platformio.packages_dir}/tool-avrdude@1.60300.200527/avrdude.conf
;     -p
;     $BOARD_MCU
;     -P
;     $UPLOAD_PORT
;     -c
;     usbasp
; upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i


; device is Arduino as ISP

upload_protocol = stk500v1
upload_port = /dev/ttyACM0
upload_speed = 19200
; upload_protocol = custom
; upload_port = /dev/ttyACM0
; upload_speed = 19200
; ; monitor_port = /dev/ttyACM0
; ; monitor_speed = 57600
upload_flags =
    ; -C
    ; ; use "tool-avrdude-megaavr" for the atmelmegaavr platform
    ; ; ${platformio.packages_dir}/tool-avrdude/avrdude.conf
    ; ${platformio.packages_dir}/tool-avrdude@1.60300.200527/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -b
    $UPLOAD_SPEED
    ; -c
    ; stk500v1
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

And the result…

...
Indexing .pio/build/attiny85/libFrameworkArduino.a
Linking .pio/build/attiny85/firmware.elf
Checking size .pio/build/attiny85/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   1.8% (used 9 bytes from 512 bytes)
Flash: [          ]   3.0% (used 248 bytes from 8192 bytes)
Building .pio/build/attiny85/firmware.hex
Configuring upload protocol...
AVAILABLE: stk500v1
CURRENT: upload_protocol = stk500v1
Looking for upload port...
Uploading .pio/build/attiny85/firmware.hex
avrdude: can't open config file "/home/jenkins/workspace/avrdude/label/Ubuntu12.04x64/objdir/etc/avrdude.conf": No such file or directory
avrdude: error reading system wide configuration file "/home/jenkins/workspace/avrdude/label/Ubuntu12.04x64/objdir/etc/avrdude.conf"
*** [upload] Error 1

If it helps any, I dug out an old sketch with an ATtiny85, it’s just the “Blink” sketch, but here are the details.

My platformio.ini file

[env:attiny85]
platform=atmelavr
board=attiny85
framework=arduino
upload_protocol=usbtiny

My execution of the command pio run -t upload -v, obvioulsy after I did pio run to compile the sketch.

norman@Hubble2:~/Arduino/attiny_blink$ pio run -t upload -v
Processing attiny85 (platform: atmelavr; board: attiny85; board_build.f_cpu: 1000000; framework: arduino; upload_protocol: usbtiny)
----------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/attiny85.html
PLATFORM: Atmel AVR (5.0.0) > Generic ATtiny85
HARDWARE: ATTINY85 1MHz, 512B RAM, 8KB Flash
DEBUG: Current (simavr) External (simavr)
PACKAGES: 
 - framework-arduino-avr-attiny @ 1.5.2 
 - tool-avrdude @ 1.60300.200527 (6.3.0) 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
avr-g++ -o "/home/norman/Arduino/attiny_blink/attiny_blink/attiny_blink.ino.cpp" -x c++ -fpreprocessed -dD -E "/tmp/tmp00zpx_ov"
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 9 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
avr-g++ -o .pio/build/attiny85/src/attiny_blink.ino.cpp.o -c -fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -mmcu=attiny85 -Os -Wall -ffunction-sections -fdata-sections -flto -DPLATFORMIO=60116 -DARDUINO_AVR_ATTINYX5 -DF_CPU=1000000 -DARDUINO_ARCH_AVR -DARDUINO=10808 -DCLOCK_SOURCE=0 -DNEOPIXELPORT=PORTB -Iattiny_blink -I/home/norman/.platformio/packages/framework-arduino-avr-attiny/cores/tiny -I/home/norman/.platformio/packages/framework-arduino-avr-attiny/variants/tinyX5 attiny_blink/attiny_blink.ino.cpp
avr-g++ -o .pio/build/attiny85/firmware.elf -mmcu=attiny85 -Os -Wl,--gc-sections -flto -fuse-linker-plugin .pio/build/attiny85/src/attiny_blink.ino.cpp.o -L.pio/build/attiny85 -Wl,--start-group .pio/build/attiny85/libFrameworkArduinoVariant.a .pio/build/attiny85/libFrameworkArduino.a -lm -Wl,--end-group
MethodWrapper(["checkprogsize"], [".pio/build/attiny85/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   1.8% (used 9 bytes from 512 bytes)
Flash: [=         ]   5.9% (used 484 bytes from 8192 bytes)
.pio/build/attiny85/firmware.elf  :
section                    size      addr
.text                       484         0
.data                         0   8388704
.bss                          9   8388704
.comment                     17         0
.note.gnu.avr.deviceinfo     60         0
.debug_aranges               64         0
.debug_info                1400         0
.debug_abbrev              1040         0
.debug_line                 258         0
.debug_str                  361         0
Total                      3693
<lambda>(["upload"], [".pio/build/attiny85/firmware.hex"])
AVAILABLE: usbtiny
CURRENT: upload_protocol = usbtiny
BeforeUpload(["upload"], [".pio/build/attiny85/firmware.hex"])
avrdude -v -p attiny85 -C /home/norman/.platformio/packages/tool-avrdude/avrdude.conf -c usbtiny -e -D -U flash:w:.pio/build/attiny85/firmware.hex:i

avrdude: Version 6.3, compiled on Sep 12 2016 at 15:21:49
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/norman/.platformio/packages/tool-avrdude/avrdude.conf"
         User configuration file is "/home/norman/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: 003:016
         AVR Part                      : ATtiny85
         Chip Erase delay              : 400000 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    12     4    0 no        512    4      0  4000  4500 0xff 0xff
           flash         65     6    32    0 yes      8192   64    128 30000 30000 0xff 0xff
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e930b (probably t85)
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF
avrdude: erasing chip
avrdude: Using SCK period of 10 usec
avrdude: reading input file ".pio/build/attiny85/firmware.hex"
avrdude: writing flash (484 bytes):

Writing | ################################################## | 100% 0.70s

avrdude: 484 bytes of flash written
avrdude: verifying flash memory against .pio/build/attiny85/firmware.hex:
avrdude: load data flash data from input file .pio/build/attiny85/firmware.hex:
avrdude: input file .pio/build/attiny85/firmware.hex contains 484 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.90s

avrdude: verifying ...
avrdude: 484 bytes of flash verified

avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK (E:FF, H:DF, L:62)

avrdude done.  Thank you.

And the code uploaded to the ATtiny85, which is now blinking an LED on Arduino pin D3 aka PB4. I have the fuses set to run on the 1 MHz clock for F_CPU. Programmer is a USBtiny.

This is on Linux Mint 21.3 which is based on Ubuntu Jammy, itself based on Debian.

HTH

Cheers,
Norm.

@maxgerhardt Hi Max
Thanks for the response. Your Option 1 worked but I’m keen to understand how to know what instance of tool-avrdude to use.
Option 2 glitched - see my previously updated reply.
Thanks