Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 1 | .. _Kconfig_system: |
| 2 | |
| 3 | ################## |
| 4 | The Kconfig System |
| 5 | ################## |
| 6 | The Kconfig system is an additional tool for users to change configuration options of TF-M. |
| 7 | |
| 8 | .. figure:: kconfig_header_file_system.png |
| 9 | |
| 10 | It handles dependencies and validations automatically when you change configurations so that the |
| 11 | generated configuration options are always valid. |
| 12 | |
| 13 | It consists of `The Kconfig tool`_ and the `The Kconfig files`_. |
| 14 | |
| 15 | **************** |
| 16 | The Kconfig tool |
| 17 | **************** |
| 18 | The Kconfig tool is a python script based on `Kconfiglib <https://github.com/ulfalizer/Kconfiglib>`__ |
| 19 | to 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 Shen | dfddc98 | 2022-11-29 15:08:19 +0800 | [diff] [blame^] | 30 | Component options are gathered together in a seperate menu ``TF-M component configs`` in |
| 31 | `The Kconfig files`_. |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 32 | |
Jianliang Shen | dfddc98 | 2022-11-29 15:08:19 +0800 | [diff] [blame^] | 33 | - The .config and .config.old files |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 34 | |
| 35 | The ``.config`` file which contains all the above configurations in the Kconfig format. |
Jianliang Shen | dfddc98 | 2022-11-29 15:08:19 +0800 | [diff] [blame^] | 36 | 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 Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 40 | |
| 41 | How To Use |
| 42 | ========== |
Jianliang Shen | dfddc98 | 2022-11-29 15:08:19 +0800 | [diff] [blame^] | 43 | The script takes four arguments at maximum. |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 44 | |
| 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 Shen | dfddc98 | 2022-11-29 15:08:19 +0800 | [diff] [blame^] | 60 | - '-p', '--platform-path' |
| 61 | |
| 62 | Optional. The platform specific Kconfig or defconfig files. |
| 63 | |
| 64 | Here 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 | |
| 74 | The script can be used as a standalone tool. You can pass the config files to |
| 75 | build system via command line option ``TFM_EXTRA_CONFIG_PATH`` and |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 76 | ``PROJECT_CONFIG_HEADER_FILE`` respectively, as mentioned above. |
| 77 | |
Jianliang Shen | dfddc98 | 2022-11-29 15:08:19 +0800 | [diff] [blame^] | 78 | .. 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 Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 84 | The TF-M build system has also integrated the tool. |
Jianliang Shen | dfddc98 | 2022-11-29 15:08:19 +0800 | [diff] [blame^] | 85 | You only need to set ``USE_KCONFIG_TOOL`` to ``ON/TRUE/1`` in commande line and CMake will launch |
| 86 | the GUI menuconfig for users to adjust configurations and automatically load the generated config |
| 87 | files. |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 88 | |
| 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 | ***************** |
| 96 | The Kconfig files |
| 97 | ***************** |
Jianliang Shen | dfddc98 | 2022-11-29 15:08:19 +0800 | [diff] [blame^] | 98 | The Kconfig files are the files written by the |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 99 | `Kconfig language <https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html#kconfig-language>`__ |
| 100 | to describe config options. |
Jianliang Shen | dfddc98 | 2022-11-29 15:08:19 +0800 | [diff] [blame^] | 101 | They also uses some Kconfiglib extensions such as optional source ``osource`` and relative source ``rsource`` |
| 102 | so they can only work with the Kconfiglib. |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 103 | |
| 104 | -------------- |
| 105 | |
| 106 | *Copyright (c) 2022, Arm Limited. All rights reserved.* |