Custom named binary firmware does not overwrite once re-compiled?

Hi,

I was renaming the build binary in .ini and it seems when ever I compile, the build binary doesn’t get overwrite by the new binary (seems like the firmware doesn’t even attempt to build from scratch ) .Is this how pio suppose to work or is there way to overwrite the existing binary which has the same name?
or do we need to run pio run -t clean before compiling ?

my .ini is ;

[env]

platform = ststm32
board = nucleo_f767zi
framework = arduino
upload_protocol = serial
build_flags =

-D VERSION =“2.0”

Thanks.

@maxgerhardt any comment on this would be appreciated.

How? I don’t see a script in there that would rename the firmware.bin to something else.

Also the string macro doesn’t look correctly escaped in accordance to
https://docs.platformio.org/en/latest/projectconf/sections/env/options/build/build_flags.html#stringification

Hi @maxgerhardt this is the script i used,

Import(“env”)

firmware_ver = None

my_flags = env.ParseFlags(env[‘BUILD_FLAGS’])
for x in my_flags.get(“CPPDEFINES”):
# some flags are just defines without value instead of key, value pair
if isinstance(x, list):
# grab as key, value
k, v = x
if k == “VERSION”:
firmware_ver = v
# no need to iterate further
break

env.Replace(PROGNAME=firmware_ver)

But it’s not referenced in

What’s the full platformio.ini?

sorry i didn’t copy the whole .ini

[env]

platform = ststm32
board = nucleo_f767zi
framework = arduino
upload_protocol = serial
build_flags =

-D VERSION =“2.0”

extra_scripts =
pre:scripts/firmware-name.py

So there’s only the global environment? No [env:xyz]?

There is an env :xyz which in my case

[env:development]

extends = env:dev-xyz

where as ;
[env:dev-xyz]
lib_deps =
${env.lib_deps}

build_flags =
${env.build_flags}

extra_scripts =
${env.extra_scripts}

Also, I used env development when compiling the code.