.. _kconfig-functions: Custom Kconfig Preprocessor Functions ##################################### Kconfiglib supports custom Kconfig preprocessor functions written in Python. These functions are defined in :zephyr_file:`scripts/kconfig/kconfigfunctions.py`. .. note:: The official Kconfig preprocessor documentation can be found `here `__. Most of the custom preprocessor functions are used to get devicetree information into Kconfig. For example, the default value of a Kconfig symbol can be fetched from a devicetree ``reg`` property. Devicetree-related Functions **************************** The functions listed below are used to get devicetree information into Kconfig. See the Python docstrings in :zephyr_file:`scripts/kconfig/kconfigfunctions.py` for detailed documentation. The ``*_int`` version of each function returns the value as a decimal integer, while the ``*_hex`` version returns a hexadecimal value starting with ``0x``. .. code-block:: none $(dt_alias_enabled,) $(dt_chosen_bool_prop, , ) $(dt_chosen_enabled,) $(dt_chosen_has_compat,) $(dt_chosen_label,) $(dt_chosen_path,) $(dt_chosen_reg_addr_hex,[,,]) $(dt_chosen_reg_addr_int,[,,]) $(dt_chosen_reg_size_hex,[,,]) $(dt_chosen_reg_size_int,[,,]) $(dt_compat_enabled,) $(dt_compat_on_bus,,) $(dt_gpio_hogs_enabled) $(dt_has_compat,) $(dt_node_bool_prop,,) $(dt_node_has_compat,,) $(dt_node_has_prop,,) $(dt_node_int_prop_hex,,[,]) $(dt_node_int_prop_int,,[,]) $(dt_node_parent,) $(dt_node_reg_addr_hex,[,,]) $(dt_node_reg_addr_int,[,,]) $(dt_node_reg_size_hex,[,,]) $(dt_node_reg_size_int,[,,]) $(dt_node_str_prop_equals,,,) $(dt_nodelabel_array_prop_has_val, , , ) $(dt_nodelabel_bool_prop,,) $(dt_nodelabel_enabled,) $(dt_nodelabel_enabled_with_compat,,) $(dt_nodelabel_has_compat,,) $(dt_nodelabel_has_prop,,) $(dt_nodelabel_path,) $(dt_nodelabel_reg_addr_hex,[,,]) $(dt_nodelabel_reg_addr_int,[,,]) $(dt_nodelabel_reg_size_hex,[,,]) $(dt_nodelabel_reg_size_int,[,,]) $(dt_path_enabled,) $(shields_list_contains,) Example Usage ============= Assume that the devicetree for some board looks like this: .. code-block:: devicetree { soc { #address-cells = <1>; #size-cells = <1>; spi0: spi@10014000 { compatible = "sifive,spi0"; reg = <0x10014000 0x1000 0x20010000 0x3c0900>; reg-names = "control", "mem"; ... }; }; The second entry in ``reg`` in ``spi@1001400`` (``<0x20010000 0x3c0900>``) corresponds to ``mem``, and has the address ``0x20010000``. This address can be inserted into Kconfig as follows: .. code-block:: kconfig config FLASH_BASE_ADDRESS default $(dt_node_reg_addr_hex,/soc/spi@1001400,1) After preprocessor expansion, this turns into the definition below: .. code-block:: kconfig config FLASH_BASE_ADDRESS default 0x20010000