PlatformIO Community

How to set fuses [file]

Hello,
When I run platformio.exe run --target fuses, PIO gets output Do not know how to make File target 'fuses' (D:\.Dokumenty\PlatformIO\atMega_Therm\fuses).
How can I use this?
Thx

What is the platformio.ini for this project?

I make everything copy&paste from docs with changed f_cpu and fuses.
My files:
platformio.ini

[env:ATmega328P]
platform = atmelavr
board = ATmega328P
framework = arduino
board_build.f_cpu = 8000000UL

lib_deps = 
    OneWire
    DallasTemperature

extra_scripts = extra_script.py

and extra_script.py

Import('env')
env.Replace(FUSESCMD="avrdude $UPLOADERFLAGS -e -Ulock:w:0x3F:m -Uhfuse:w:0xDA:m -Uefuse:w:0xFD:m -Ulfuse:w:0xE2:m")

And retuns some warn

I can can confirm that this does not work as it’s shown in the documentation.

platformio.ini and extra_script.py with empty firmware logic also gives me

pio run -t fuses
Processing forum2 (platform: atmelavr; board: ATmega328P; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/ATmega328P.html
PLATFORM: Atmel AVR 1.15.0 > ATmega328P/PA
HARDWARE: ATMEGA328P 8MHz, 2KB RAM, 31.50KB Flash
PACKAGES: toolchain-atmelavr 1.50400.190710 (5.4.0), framework-arduinoavr 4.1.1, tool-avrdude 1.60300.190424 (6.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 11 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <OneWire> 2.3.4 (C:\Users\Maxi\Documents\stackoverflow_testing\.pio\libdeps\forum2\OneWire_ID1)
|-- <DallasTemperature> 3.8.0 (C:\Users\Maxi\Documents\stackoverflow_testing\.pio\libdeps\forum2\DallasTemperature_ID54)
|   |-- <OneWire> 2.3.4 (C:\Users\Maxi\Documents\stackoverflow_testing\.pio\libdeps\forum2\OneWire_ID1)
*** Do not know how to make File target `fuses' (C:\Users\Maxi\Documents\stackoverflow_testing\fuses).  Stop.
============================================= [FAILED] Took 1.72 seconds =============================================

@ivankravets Is that reproducable on your side? Has the command maybe changed?

1 Like

It does work for board uno.

So it seems to make a difference if the board definition declares fuses (like uno) or if it doesn’t (like ATmega328P).

1 Like

Yeah, I tried it out also but on a pro8MHzatmega328 and it seemed like it would work fine, but I didn’t have the programmer hooked up so it then failed to set/read the fuses (which I expected).

I have the same issue as [Mikolaj98p] or [maxgerhardt]. Are there any hints to solve this issue. My platformio.ini is set-up for Attiny85 with arduino framework, nothing special.

[env:release]
platform = atmelavr
board = attiny85
board_build.mcu = attiny85
board_build.f_cpu = 8000000L
framework = arduino
upload_protocol = usbasp
; each flag in a new line
upload_flags =
-Pusb

; to override default fuse with custom fuse settings use an extra script
extra_scripts = fuse_settings.py

With the introduction of the fuses target, it looks like the fuse values need to be configured like so in your platformio.ini:

; Arduino Pro Mini Atmega328 8Mhz
board_fuses.hfuse = 0xDA
board_fuses.lfuse = 0xFF
board_fuses.efuse = 0xFD

You may not even need the extra_scripts helper any more… worth commenting that out and trying… e.g. pio run -t fuses or the Set fuses project task (I’d try it myself but don’t have willing victim or programmer handy atm).

I can confirm that it works as you wrote. I made some trials. Now everything needed for configuration is embedded in the platformio.ini - fantastic. Many thx for immediate help and support

1 Like

Fantastic :slight_smile: Means I can retire the extra_script I’ve been using the next time I need to do the fuses! :slight_smile:

Doesn’t work for me :frowning:
platformio.ini :
[env:attiny85]
platform = atmelavr
board = attiny85
board_build.f_cpu = 8000000L
board_fuses.hfuse = 0xDF
board_fuses.lfuse = 0xE2
upload_protocol = stk500v2
; each flag in a new line
upload_flags =
-Pusb

But fuses are not set:
avrdude: Device signature = 0x1e930b (probably t85)
avrdude: erasing chip
avrdude: reading input file “.pio/build/attiny85/firmware.hex”
avrdude: writing flash (264 bytes):

Writing | ################################################## | 100% 0.13s

avrdude: 264 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 264 bytes
avrdude: reading on-chip flash data:

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

avrdude: verifying …
avrdude: 264 bytes of flash verified
avrdude: safemode: Fuses OK (E:FF, H:DF, L:62)
avrdude done. Thank you.

Anything I made wrong?

Are you actually setting the fuses? i.e. running the Set Fuses or Upload using Programmer and Set Fuses task? As the fuses should not be set during a normal upload.

1 Like

Ok. I didn’t know that you need a special task for this purpose.
I thought this would be done in a ‘normal’ upload if the additional lines with the fuse settings are defined in the platformio.ini file.
Running the special task ‘Set Fuses’ works.
Thanks for the fast help, but I could not derive this information from the docu…

1 Like

During a ‘normal’ run of avrdude, it never sets the fuses… IIRC… that’s why it also says ‘safemode’ in relation to the fuses. But it is worth mentioning that in the platformio docs also, as it is somewhat unclear if you’re not familar with the behaviour of the underlying tools :wink: If you’ve come from Arduino IDE land, this is why you use the ‘Burn Bootloader’ command on new parts (even those like the attiny85 which have no bootloader)… as that’s the only time avrdude is run in ‘set the fuses’ mode (or is that ‘light the fuses’?).

Correct. I like the platformio IDE very much (as it is a ‘real’ IDE in comparison with the Arduino IDE). And it is quite intuitive to use. Just setting the fuses was not that clear to me. The only thing I’m missing now is some kind of simulator (like in AVRStudio). But maybe it is also already there and I was just too impatient to find out how it works…