Advanced building procedures

You can customize the basic building procedures in a variety of ways, depending on the configuration of your project.

Advanced compiler settings

The application has full control over the build process.

Using Zephyr’s configuration options is the standard way of controlling how the system is built. These options can be found under Zephyr’s menuconfig Build and Link Features > Compiler Options. For example, to turn off optimizations, select CONFIG_NO_OPTIMIZATIONS.

Compiler options not controlled by the Zephyr build system can be controlled through the CONFIG_COMPILER_OPT Kconfig option.

Configuring build types

When the CONF_FILE variable contains a single file and this file name follows the naming pattern prj_<buildtype>.conf, then the build type will be inferred to be <buildtype>. The build type cannot be set explicitly. The <buildtype> can be any string, but it is common to use release and debug.

For information about how to set variables, see Important Build System Variables in the Zephyr documentation.

The following software components can be made dependent on the build type:

  • The Partition Manager’s static configuration. When the build type has been inferred, the file pm_static_<buildtype>.yml will have precedence over pm_static.yml.

  • The child image Kconfig configuration. Certain child image configuration files located in the child_image/ directory can be defined per build type.

The devicetree configuration is not affected by the build type.


For an example of an application that uses build types, see the nRF Desktop application (nRF Desktop build types) or the nRF Machine Learning application (nRF Machine Learning build types).

To select the build type in the nRF Connect for VS Code extension:

  1. When building an application as described in the nRF Connect for VS Code extension documentation, follow the steps for setting up the build configuration.

  2. In the Add Build Configuration screen, select the desired .conf file from the Configuration drop-down menu.

  3. Fill in other configuration options, if applicable, and click Build Configuration.

If the selected board does not support the selected build type, the build is interrupted. For example, for the nRF Machine Learning application, if the nus build type is not supported by the selected board, the following notification appears:

Configuration file for build type ``nus`` is missing.

Optional build parameters

Here are some of the possible options you can use:

  • You can include the directory_name parameter to build from a directory other than the current directory.

  • You can use the build_target@board_revision parameter to get extra devicetree overlays with new features available for a board version. The board_revision is printed on the label of your DK, just below the PCA number. For example, if you run the west build command with an additional parameter @1.0.0 for nRF9160 build target, it adds the external flash on the nRF9160 DK that was available since board version v0.14.0.

  • You can start menuconfig with the west command to configure your application.

  • You can reuse an existing build directory for building another application for another board or build target by passing -p=auto to west build.

For more information on other optional build parameters, run the west build -h help text command.