Board_build.f_cpu parameter has no effect on Attiny85

Hello,

I am attempting to upload my code onto an attiny85 chip, while using arduino as ISP programmer.
The code uploads fine, but the cpu speed is wrong. I have set the fuses on the attiny to run at 8Mhz internal (no divider) and uploaded this simple sketch

void setup()

{

    pinMode(PB4, OUTPUT);

    while(true)

    {

        digitalWrite(PB4, HIGH);   // turn the LED on (HIGH is the voltage level)

        delay(1000);                       // wait for a second

        digitalWrite(PB4, LOW);    // turn the LED off by making the voltage LOW

        delay(1000);                       // wait for a second

    }
}

It blinks, but too slow, instead of 1 second blinks, i get 2s light on and 2s light off. If i upload this same code through Arduino IDE, it works correctly.

This is my platformio.ini config

[env:attiny85]

platform = atmelavr

framework = arduino

board = attiny85

board_build.f_cpu = 8000000L

upload_protocol = stk500v1

; each flag in a new line

upload_flags =

    -P$UPLOAD_PORT

    -b$UPLOAD_SPEED

; edit these lines

upload_port = COM9

upload_speed = 19200

it appears as if the board_build.f_cpu parameter has no effect at all, even if i change it to 1000000L, the speed of the blinks doesn’t change at all.

This suggest the clock is running twice as slow as it should be.

What are the last few lines of output after uploading that show the value of the fuses?

avrdude: safemode: Fuses OK (E:FF, H:DE, L:E2)

Per board file, platform.py and arduino.py this is using the tiny core of the GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8 repository.

Most importantly, the board file pre-selects a clock source setting for you

which according to

means PLL instead of pure internal, undivided oscillator. The README page page describes the meaning of all possible CLOCK_SOURCE values, with 0 meaning

0 - Internal 8MHz oscillator, not prescaled, or prescaled to 1 MHz (ie, fully set by fuses)

And hence I suggest the usage of a build_unflags directive to remove the erroneous define and inject a new one. Add

build_unflags = -DCLOCK_SOURCE=6
build_flags = -DCLOCK_SOURCE=0

to the platformio.ini and retry.