Fuses not uploaded acording .ini file

Hey Community,

I have a problem while uploading fuses to a custom board with a atmgega 324pb. With Atmel Studio uploading works without problems.

I tried to upload the fuses via Platformio-> Platform-> Set Fuses

i have the following .ini file

[env:ATmega324PB]
platform = atmelavr
board = ATmega324PB
framework = arduino
board_build.f_cpu = 8000000L
board_fuse.lfuse = 0xD2
board_fuse.hfuse = 0xD1
board_fuse.efuse = 0xF7

upload_protocol = custom
upload_port = usb
upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -c
    avrispmkII
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

But got the following output in the Terminal while uploading

TARGET CONFIGURATION:
---------------------
Target = atmega324pb
Clock speed = 8000000L
Oscillator = external
BOD level = 2.7v
Save EEPROM = yes
UART port = uart0
Clock output = no
JTAG enable = no
CFD enable = no
---------------------
Warning: The `custom` upload protocol is used! The upload and fuse flags may conflict!
More information: https://docs.platformio.org/en/latest/platforms/atmelavr.html#overriding-default-fuses-command

Selected fuses: [lfuse = 0xff, hfuse = 0xd6, efuse = 0xf5]
Setting fuses

These Fuse are different from the fuseses in the .ini file and “destroyed” my µC. How can i prevent to upload the wrong fuses

Did you follow the link in the output

So if you add

extra_scripts = correct_fuses.py

with correct_fuses.py

Import("env")

env.Replace(
    FUSESFLAGS=[
        "-Uhfuse:w:0xD1:m",
        "-Uefuse:w:0xF7:m",
        "-Ulfuse:w:0xD2:m",
        "-Ulock:w:0xFF:m"
    ]
)

i followed the link but i have not quite understood. Why do i have do define the fuses seperatly. i dont want them to be written with every flash process. only if i manually write the fuses.
But thanks for your answer.