PlatformIO Community

Change name of firmware file

Hi, I would like to have custom firmware name, instead of firmware.bin i would like IotSwitch.bin file to be generated. Is it possible to configure?

Hi there. Thank you for this info, but where in Platform.ini do I put this code?
Do I just copy and paste it just like it is:

platform = espressif32
board = featheresp32
framework = arduino
lib_deps =
build_flags = -D VERSION=1.1.3
extra_scripts =
monitor_speed = 115200

Or what part of this code do I use in my specific board’s env section:

platform = ${common_LPC.platform}
extends = common_LPC
board = nxp_lpc1769

The critical part is the definition of the verseion via build_flags and the definition of the extra_script to run. So just add the lines

build_flags = -D VERSION=13
extra_scripts =

to the environment and make sure that the with the content as shown in the docs exists in the project root folder. Refer to the docs for all further documentation on platformio.ini options.

So the script must be exactly this:

And put into the root dirctory like this:

But where in platform.ini do I put what to call that script?

Well through the extra_scripts = line… Please see docs and the therein linked docs…

You mean, like this:


Can you show the contents of your in VSCode? Is the first line Import("env") as it should or Import("projenv"). Not being able to reference projenv is correct for pre: scripts as per docs.

Though there might be secondary error after that: The given example doesn’t work when there defines in the build script that are not defined to some value, but just defined. Because then the CPPDEFINES will e.g. be


and viewing them as (key, value) pairs as the code

defines = {k: v for (k, v) in my_flags.get("CPPDEFINES")}

does fails since the first item cannot be written in such a way.

But let’s see your file content first. The directives in the platformio.ini are correct.

1 Like

A better, more general script for converting the -D VERSION=14 into the firmware name would be


version_from_buildflags = "not_found"
my_flags = env.ParseFlags(env['BUILD_FLAGS'])
# some flags are just defines without value
# some are key, value pairs
for x in my_flags.get("CPPDEFINES"):
    if isinstance(x, list):
        # grab as key, value
        k, v = x
        if k == "VERSION":
            version_from_buildflags = v
            # no need to iterate further

env.Replace(PROGNAME="firmware_%s" % str(version_from_buildflags))
1 Like

Thank you.
I’ll try that today.
But how do I call this script and where in platformio.ini file?
Currently I have this:

build_flags = -D VERSION=1.1
extra_scripts =


I had somebody else’ script with that projenv name thingi…

So I changed to another script without that.
This example shows that I need to define the platform, board and framework etc to call this script?

platform = espressif8266
board = nodemcuv2
framework = arduino
build_flags = -D VERSION=13
extra_scripts =

I am currently running the BTT SKR1.4 turbo board with tmc2209 drivers…

And with this setup, I still only get the firmware.bin file instead of the firmware version number…