You are currently not logged in and your progress will not be saved. Register or Log in

Configuration files

Application and board configurations

Each application in nRF Connect SDK must have an application configuration file, usually called prj.conf, that describes the software modules and kernel services used and their settings. The application configuration file is text-based and contains configuration options (often called symbols) in the form of:

CONFIG_<symbol_name>=<value>

Each configuration option must start with the prefix CONFIG_ followed by the name of the software module to configure, then the value to be set, with no spaces around the equals sign.

Let’s take a look at the application configuration file prj.conf from the blinky sample, which we covered in-depth in the previous lesson.

This file has only one line, seen below, that includes the GPIO driver.

CONFIG_GPIO=y

In other words, setting the CONFIG_GPIO-symbol will enable the inclusion of the source code of the GPIO driver into the build process and hence our application will be able to use it.

In addition to the application configuration file, an application inherits the board configuration file, <board_name>_defconfig, of the board that the application is built for.

Let’s take an example, the nRF52833 DK has the board configuration file nrf52833dk_nrf52833_defconfig available in <nRF Connect SDK Installation Path>\zephyr\boards\arm\nrf52833dk_nrf52833.

# SPDX-License-Identifier: Apache-2.0

CONFIG_SOC_SERIES_NRF52X=y
CONFIG_SOC_NRF52833_QIAA=y
CONFIG_BOARD_NRF52833DK_NRF52833=y

# Enable MPU
CONFIG_ARM_MPU=y

# Enable hardware stack protection
CONFIG_HW_STACK_PROTECTION=y

# Enable RTT
CONFIG_USE_SEGGER_RTT=y

# enable GPIO
CONFIG_GPIO=y

# enable uart driver
CONFIG_SERIAL=y

# enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

# additional board options
CONFIG_GPIO_AS_PINRESET=y

board configuration file for the nRF52833 DK: nrf52833dk_nrf52833_defconfig

Note

Configuration options can be set both in the application configuration file and the board configuration file. In the example, CONFIG_GPIO symbol is set in both files. In this case, the value in the application configuration file always takes precedence.

The first three lines in the board configuration file includes software support specific to the nRF52833 DK and its nRF52833 SoC. The CONFIG_ARM_MPU is for the memory protection unit. This brings us to the question: How can we know the meaning of all these configuration options?

If you are using nRF Connect for VS Code, simply hovering the mouse over the configuration symbol will show a box that contains a description about the symbol.

In addition to that, you could visit the documentation webpage and find the documentation for the specific symbol, for instance, CONFIG_GPIO. Another way is by using an interface called guiconfig, which will be covered in the next section.

Further examining the board configuration file of the nRF52833 DK, we can see that the UART driver (CONFIG_SERIAL), the RTT drivers, and libraries (CONFIG_USE_SEGGER_RTT) and the console drivers (CONFIG_CONSOLE) are included. CONFIG_UART_CONSOLE will make UART the default console output. All these software components are core to the process of interacting with a console.

Note

You should never modify any board configuration files. Instead, rely on the application configuration file to set new configurations and subsequently overwrite any default board configurations if needed.  If you change the board configuration file directly then these changes will apply for all projects using that board.

Graphical configuration interface (guiconfig)

In nRF Connect SDK, symbols are grouped into menus and sub-menus to be able to easily browse all available configurations.

The graphical configuration interface (guiconfig) is an easy way to view the merged configurations of both the application and the board in one organized graphical representation, in addition to browsing all related configuration options and seeing their default values.

It is important to note that guiconfig does not set configurations permanently. Configurations should only be set in the application configuration file.

Open guiconfig by typing the following command in the application directory after building the application

west build -t guiconfig

Or by finding Guiconfig under Actions in nRF Connect for VS Code.

Guiconfig available in the Actions window of nRF Connect for VS Code

If you don’t see guiconfig in the Action window, go to the menu File -> Preferences -> Settings and type nrf-connect.kconfig.interface. In the drop-down menu, select guiconfig as shown in the image below:

File -> Preferences -> Settings in nRF Connect for VS Code

guiconfig is organized into menus that group related configurations together, such as Device Drivers, C Library, and Boot Options. Menus can have submenus, and submenus can have submenus of their own. If we expand any of these menus, for instance, Device Drivers, all symbols related to this category will show up, some with menus of their own.

guiconfig in nRF Connect for VS Code
blinky sample

The green X indicates the modules that are enabled in the application, either from the board configuration file or the application configuration file. For instance, we can see that the GPIO Drivers are enabled in the blinky sample.

To find out what configuration you need to add in the application configuration file to enable a specific module, select the “Show name” option. The name of the relevant module will show up to the right, and you can enable it by adding it to the application configuration file after the CONFIG_ prefix.

Guiconfig: do’s and don’ts

Do: Use guiconfig to explore related configurations options and know their default values.

It is useful to enable the Show name option as it will give you the name of the configuration symbol to be set in the application configuration file. Note that the name will be missing the CONFIG_ prefix, so you must add the prefix when enabling it in the file. 

Don’t: Use guiconfig to set configurations as they will be lost.

guiconfig works by opening a temporary file called .config generated after a build. The .config is present in the directory <Application Directory>/build/zephyr/ and contains the merged configurations of the application configuration, board configuration and the default configurations set by the nRF Connect SDK. Anytime you do a clean build, all the configurations set through the guiconfig will be lost.

Note

There are three interactive Kconfig interfaces (Kconfig, guiconfig, menuconfig) supported by nRF Connect for VS code. They all allow you to explore related configurations options and know their default values, pick your favorite interface.