Section [env]

Each project may have multiple configuration environments defining the available project tasks for building, programming, debugging, unit testing, device monitoring, library dependencies, etc. The configuration environments are declared using [env] sections in “platformio.ini” (Project Configuration File).

The allowed options are listed under Options.

Common [env]

An optional configuration environment with common options that will be shared between all [env:NAME] environments in the platformio.ini file. It is very useful if the configuration file has a lot of environments [env:NAME] and they share common settings.

For example:

[env]
platform = ststm32
framework = stm32cube
board = nucleo_l152re
lib_deps = Dep1, Dep2

[env:release]
build_flags = -D RELEASE
lib_deps =
    ${env.lib_deps}
    Dep3

[env:debug]
build_type = debug
build_flags = -D DEBUG
lib_deps = DepCustom

In this example we have two configuration environments release and debug. This is equivalent to duplicating all options as shown below:

[env:release]
platform = ststm32
framework = stm32cube
board = nucleo_l152re
build_flags = -D RELEASE
lib_deps = Dep1, Dep2, Dep3

[env:debug]
platform = ststm32
framework = stm32cube
board = nucleo_l152re
build_type = debug
build_flags = -D DEBUG
lib_deps = DepCustom

Working [env:NAME]

A section with an env: prefix defines a working environment for pio run, pio test, pio check, pio debug and other commands. Multiple [env:NAME] environments with different NAME are allowed. Every project must define at least one working environment.

Each environment must have a unique NAME. The valid chars for NAME are letters a-z, numbers 0-9, special char _ (underscore). For example, [env:hello_world].

If you have multiple working environments and you need to process only a few of them, the commands mentioned above accept the -e, --environment option to select a subset of the working environments to process. The [platformio] default_envs option can be used to define a default set of working environments for the commands to process.

Options