# Section `[env]`

- Common `[env]`

- Environment `[env:NAME]`

- Options

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]`

New in version 4.0.

An optional configuration environment with common options that will be shared between all `[env:NAME]` environments in the platform.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

## Environment `[env:NAME]`

A section with an `env:` prefix defines a working environment for platformio run, platformio test, platformio check, platformio 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

- Platform options
  - `platform`
  - `platform_packages`
  - `framework`
  - `board`
  - `board_build.mcu`
  - `board_build.f_cpu`
  - `board_build.ldscript`
  - More options
- Build options
  - `build_type`
  - `build_flags`
  - `src_build_flags`
  - `build_unflags`
  - `src_filter`
  - `targets`
- Library options
  - `lib_deps`
  - `lib_ignore`
  - `lib_extra_dirs`
  - `lib_ldf_mode`
  - `lib_compat_mode`
  - `lib_archive`
- Upload options
  - `upload_port`
  - `upload_protocol`
  - `upload_speed`
  - `upload_flags`
  - `upload_resetmethod`
  - `upload_command`
- Monitor options
  - `monitor_port`
  - `monitor_speed`
  - `monitor_filters`
  - `monitor_rts`
  - `monitor_dtr`
  - `monitor_flags`
- Check options
  - `check_tool`
  - `check_patterns`
  - `check_flags`
  - `check_severity`
- Test options
  - `test_filter`
  - `test_ignore`
  - `test_port`
  - `test_speed`
  - `test_transport`
  - `test_build_project_src`
- Debugging options
  - `debug_tool`
  - `debug_build_flags`
  - `debug_init_break`
  - `debug_init_cmds`
  - `debug_extra_cmds`
  - `debug_load_cmds`
  - `debug_load_mode`
  - `debug_server`
  - `debug_port`
  - `debug_svd_path`
- Advanced options
  - `extends`
  - `extra_scripts`