Error: Dynamic fuses generation for attiny84 is not supported. Please specify fuses in platformio.ini

I am using an ATtiny84, I have a custom Optiboot bootloader, and I want to flash it with USBasp.

Flashing a normal firmware (e.g. the binary resulting in compiling the platformio project) works fine with the USBasp using ICSP.

I also specify the fuses for the AVR in my platformio.ini, yet, I get the following error:

Error: Dynamic fuses generation for attiny84 is not supported. Please specify fuses in platformio.ini

Relevant environment from the platformio.ini:

board_build.f_cpu = 16000000L
board_fuses.lfuse = 0xFF
board_fuses.hfuse = 0xDF
board_fuses.efuse = 0xFE
;board_bootloader.lock_bits = 0x0F
;board_bootloader.unlock_bits = 0x3F
platform = atmelavr
board = attiny84
framework = arduino
lib_deps =
build_flags =
board_bootloader.file = optiboot_attiny84.hex
upload_protocol = custom
upload_port = usb
upload_flags =
    ; use "tool-avrdude-megaavr" for the atmelmegaavr platform
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

I feel this must be a bug, but before I go hunting for it, is there something I’m doing wrong?

I feel like you haven’t shown your full platformio.ini. When I use your platformio.ini and comment out the build_flags and lib_deps (because they refer to a not-shown [common] section) and try to upload fuses, I instead get

>pio run -t fuses -v
Processing attiny84_usbasp (board_build.f_cpu: 16000000L; board_fuses.lfuse: 0xFF; board_fuses.hfuse: 0xDF; board_fuses.efuse: 0xFE; platform: atmelavr; board: attiny84; framework: arduino; board_bootloader.file: optiboot_attiny84.hex; upload_protocol: custom; upload_port: usb; upload_flags: -C, C:\Users\Max\.platformio\packages/tool-avrdude/avrdude.conf, -p, $BOARD_MCU, -P, $UPLOAD_PORT, -c, usbasp; upload_command: avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i)
PLATFORM: Atmel AVR (4.2.0) > Generic ATtiny84
DEBUG: Current (simavr) External (simavr)
 - 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 ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 9 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Warning: The `custom` upload protocol is used! The upload and fuse flags may conflict!
More information:

Selected fuses: [lfuse = 0xFF, hfuse = 0xDF, efuse = 0xFE]
avrdude -p attiny84 -C "C:\Users\Max\.platformio\packages\tool-avrdude@1.60300.200527\avrdude.conf" -C C:\Users\Max\.platformio\packages/tool-avrdude/avrdude.conf -p attiny84 -P usb -c usbasp -Ulock:w:0xff:m -Uhfuse:w:0xDF:m -Ulfuse:w:0xFF:m -Uefuse:w:0xFE:m
avrdude: error at C:\Users\Max\.platformio\packages/tool-avrdude/avrdude.conf:402: syntax error
avrdude: error reading system wide configuration file "C:\Users\Max\.platformio\packages/tool-avrdude/avrdude.conf"
*** [fuses] Error 1
==================================== [FAILED] Took 1.78 seconds ====================================

So it totally tries to burn the fuses but the double -C option in upload_flags screws with it. Remoiving that gives me

Selected fuses: [lfuse = 0xFF, hfuse = 0xDF, efuse = 0xFE]
avrdude -p attiny84 -C "C:\Users\Max\.platformio\packages\tool-avrdude@1.60300.200527\avrdude.conf" -p attiny84 -P usb -c usbasp -Ulock:w:0xff:m -Uhfuse:w:0xDF:m -Ulfuse:w:0xFF:m -Uefuse:w:0xFE:m
avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='' product='USBasp'

avrdude done.  Thank you.

So that should wourk when you have the actual programmer connected.

In short, make sure you run the “Set Fuses” project task in the right environtment. If you are using the commandline, use the -e <environment name> section ot specify it. If in the GUI, make sure you are selecting the Set Fuses task for the attiny84_usbasp environment.

Hi @maxgerhardt, thank you for looking into this!

You are right, the build flags might be relevant, the common env is as follows:

default_envs = attiny84_usbasp
lib_deps =
build_flags =

That said, I forgot to mention, that it will program the fuses with platformio run -t fuses no problem, this error only occurs when running platformio run -t bootloader.

Also, i’m using Platformio 6.1.6.

Well you are running in

because when burning bootloader, it looks for board_bootloader.lfuse and co, but these are not defined in your platformio.ini.

Which is indeed documented at

Ah, that’ll do it :slightly_smiling_face:

Thank you… I had no idea there was a separate specification for board_bootloader.{l,h,e}fuse. I read the same documentation, and my eyes missed this subtle difference, not expecting there to be multiple definitions for the fuses.

Which doesn’t really make too much sense, right? You are likely to have the same fuses for whatever code you’re running or flashing on the same MCU, i would imagine…