Interaction with Kconfig

The devicetree is closely related to kconfig. On one side, the devicetree aims to describe the hardware and on the other side, kconfig aims to tell what to do with it.

Kconfig is used to define a set of options to configure the GAP SDK environnement via a graphical interface: menuconfig. The following section explains how it interacts with the devicetree.

Hardware selection

As a first step, Menuconfig provides a Board menu containing a list of supported boards.

../../../_images/kconfig_select_hardware.png

Menuconfig board menu

Each board option in this list refers to a devicetree source file. Depending on which chip a board is based on, a related chip option (hidden from the user) will be automatically enabled and so its related devicetree source file.

Such kind of option must respect the following syntax to be correctly parsed after :

CONFIG_CHIP_<CHIPNAME> for a chip (hidden)

CONFIG_BOARD_<BOARDNAME> for a board

Warning

The CONFIG prefix is automatically added to the option name. Please, name your options without this prefix in Kconfig files.

Warning

Chip and board names must match their related .dts file name to be correctly linked.

Here is an example of the integration of the gap9mod board :

gap9mod_v1_0_b

As a result, depending on what option has been selected in the board menu, we get a list of dts files that will be compiled then merged to get a global and unique device tree blob (.dtb file) containing all data.

This devicetree blob file will be the input of the parser that will generate the C representation of the device tree.

../../../_images/from_menuconfig_to_main_dtb_file.png

Process to build the main devicetree blob file

Drivers selection

Menuconfig provides a Drivers menu where all the supported drivers of the selected hardware can be enabled. This menu adapt itself depending on the selected hardware in the board menu.

../../../_images/menuconfig_drivers_menu.png

Menuconfig drivers menu

Note

Enabling a driver means that the parser will pick the devicetree content refering to the physical peripheral with all its configuration data.

Such kind of option must respect the following syntax to be correctly parsed after :

CONFIG_DRIVER_<DRIVERNAME>

Note

Having CONFIG_DRIVER_MX25U51245G option enabled will select the mx25u51245g device from your board.

Default driver

For some driver categories, a default driver mechanism is implemented. It consists in automatically enable the driver of the category which is implemented on the selected board. This way, it is possible for an application to avoid making reference to a specific hardware.

As an example, if an application requires a flash but not one in particular, instead of having CONFIG_DRIVER_MX25U51245G option enabled (which is the flash of the Gap9mod board), CONFIG_DRIVER_TYPE_FLASH option can be enabled to get rid of the gap9mod reference.

Note

A driver category option name is build as the following : CONFIG_DRIVER_TYPE_<CATEGORYNAME>

Overriding devicetree property

See Use KConfig options in devicetree files tutorial