blob: f4fa257b61e2fc7e6b6ad661c0e83ab6b599af72 [file] [log] [blame]
Kevin Peng75b0b762022-10-25 18:00:27 +08001.. _Kconfig_system:
2
3##################
4The Kconfig System
5##################
6The Kconfig system is an additional tool for users to change configuration options of TF-M.
7
8.. figure:: kconfig_header_file_system.png
9
10It handles dependencies and validations automatically when you change configurations so that the
11generated configuration options are always valid.
12
13It consists of `The Kconfig tool`_ and the `The Kconfig files`_.
14
15****************
16The Kconfig tool
17****************
18The Kconfig tool is a python script based on `Kconfiglib <https://github.com/ulfalizer/Kconfiglib>`__
19to launch the menuconfig interfaces and generate the following config files:
20
21- CMake config file
22
23 Contains CMake cache variables of building options.
24 This file should be passed to the build system via command line option ``TFM_EXTRA_CONFIG_PATH``.
25
26- Header file
27
28 Contains component options in the header file system.
29 This file should be passed to the build system via the command line option ``PROJECT_CONFIG_HEADER_FILE``.
Jianliang Shendfddc982022-11-29 15:08:19 +080030 Component options are gathered together in a seperate menu ``TF-M component configs`` in
31 `The Kconfig files`_.
Kevin Peng75b0b762022-10-25 18:00:27 +080032
Jianliang Shendfddc982022-11-29 15:08:19 +080033- The .config and .config.old files
Kevin Peng75b0b762022-10-25 18:00:27 +080034
35 The ``.config`` file which contains all the above configurations in the Kconfig format.
Jianliang Shendfddc982022-11-29 15:08:19 +080036 It will be created after the first execution of the script. It is only used to allow
37 users to make adjustments basing on the previous settings.
38 The Kconfig tool will load it if it exists and ``.config.old`` will be created to
39 save the previous configurations.
Kevin Peng75b0b762022-10-25 18:00:27 +080040
41How To Use
42==========
Jianliang Shendfddc982022-11-29 15:08:19 +080043The script takes four arguments at maximum.
Kevin Peng75b0b762022-10-25 18:00:27 +080044
45- '-k', '--kconfig-file'
46
47 Required. The root Kconfig file.
48
49- '-u', '--ui'
50
51 Optional. The menuconfig interface to launch, ``gui`` or ``tui``.
52 Refer to `Menuconfig interfaces <https://github.com/ulfalizer/Kconfiglib#menuconfig-interfaces>`__
53 for interface details. Only the first two are supported.
54 If no UI is selected, the tool generates config files with default values.
55
56- '-o', '--output_path'
57
58 Required. The output directory to hold the generated files.
59
Jianliang Shendfddc982022-11-29 15:08:19 +080060- '-p', '--platform-path'
61
62 Optional. The platform specific Kconfig or defconfig files.
63
64Here is an example:
65
66.. code-block:: bash
67
68 cd trusted-firmware-m
69 python3 tools/kconfig/tfm_kconfig.py -k Kconfig -o <output_path> -u tui
70
71 # If the platform path has defconfig or Kconfig, use '-p' to load them.
72 python3 tools/kconfig/tfm_kconfig.py -k Kconfig -o <output_path> -p platform/ext/target/arm/mps2/an521
73
74The script can be used as a standalone tool. You can pass the config files to
75build system via command line option ``TFM_EXTRA_CONFIG_PATH`` and
Kevin Peng75b0b762022-10-25 18:00:27 +080076``PROJECT_CONFIG_HEADER_FILE`` respectively, as mentioned above.
77
Jianliang Shendfddc982022-11-29 15:08:19 +080078.. code-block:: bash
79
80 # Pass the files generated by script.
81 <cmake build command> -DTFM_EXTRA_CONFIG_PATH=<output_path>/project_config.cmake \
82 -DPROJECT_CONFIG_HEADER_FILE=<output_path>/project_config.h
83
Kevin Peng75b0b762022-10-25 18:00:27 +080084The TF-M build system has also integrated the tool.
Jianliang Shendfddc982022-11-29 15:08:19 +080085You only need to set ``USE_KCONFIG_TOOL`` to ``ON/TRUE/1`` in commande line and CMake will launch
86the GUI menuconfig for users to adjust configurations and automatically load the generated config
87files.
Kevin Peng75b0b762022-10-25 18:00:27 +080088
89.. note::
90
91 - Only GUI menuconfig can be launched by CMake for the time being.
92 - Due to the current limitation of the tool, you are not allowed to change the values of build
93 options that of which platforms have customized values. And there is no prompt messages either.
94
95*****************
96The Kconfig files
97*****************
Jianliang Shendfddc982022-11-29 15:08:19 +080098The Kconfig files are the files written by the
Kevin Peng75b0b762022-10-25 18:00:27 +080099`Kconfig language <https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html#kconfig-language>`__
100to describe config options.
Jianliang Shendfddc982022-11-29 15:08:19 +0800101They also uses some Kconfiglib extensions such as optional source ``osource`` and relative source ``rsource``
102so they can only work with the Kconfiglib.
Kevin Peng75b0b762022-10-25 18:00:27 +0800103
104--------------
105
106*Copyright (c) 2022, Arm Limited. All rights reserved.*