Build: Refine Kconfig system and doc
Kconfig choice supports 'optional' key word to allow
the whole choice to be toggled off to select none of the
symbols.
It is necessary to abort the kconfig tool when platform
path doesn't exist.
Add usages of Kconfig tool in the documents.
Signed-off-by: Jianliang Shen <jianliang.shen@arm.com>
Change-Id: I6c38b0bde6a5a6d099d8ea606be5e9b359216efa
diff --git a/docs/configuration/kconfig_system.rst b/docs/configuration/kconfig_system.rst
index 41a3d4f..f4fa257 100644
--- a/docs/configuration/kconfig_system.rst
+++ b/docs/configuration/kconfig_system.rst
@@ -27,16 +27,20 @@
Contains component options in the header file system.
This file should be passed to the build system via the command line option ``PROJECT_CONFIG_HEADER_FILE``.
+ Component options are gathered together in a seperate menu ``TF-M component configs`` in
+ `The Kconfig files`_.
-- The .config file
+- The .config and .config.old files
The ``.config`` file which contains all the above configurations in the Kconfig format.
- It is only used to allow users to make adjustments basing on the previous settings.
- The Kconfig tool will load it if it exists.
+ It will be created after the first execution of the script. It is only used to allow
+ users to make adjustments basing on the previous settings.
+ The Kconfig tool will load it if it exists and ``.config.old`` will be created to
+ save the previous configurations.
How To Use
==========
-The script takes three arguments at maximum.
+The script takes four arguments at maximum.
- '-k', '--kconfig-file'
@@ -53,13 +57,34 @@
Required. The output directory to hold the generated files.
-The script can be used as a standalone tool.
-You can pass the config files to build system via command line option ``TFM_EXTRA_CONFIG_PATH`` and
+- '-p', '--platform-path'
+
+ Optional. The platform specific Kconfig or defconfig files.
+
+Here is an example:
+
+.. code-block:: bash
+
+ cd trusted-firmware-m
+ python3 tools/kconfig/tfm_kconfig.py -k Kconfig -o <output_path> -u tui
+
+ # If the platform path has defconfig or Kconfig, use '-p' to load them.
+ python3 tools/kconfig/tfm_kconfig.py -k Kconfig -o <output_path> -p platform/ext/target/arm/mps2/an521
+
+The script can be used as a standalone tool. You can pass the config files to
+build system via command line option ``TFM_EXTRA_CONFIG_PATH`` and
``PROJECT_CONFIG_HEADER_FILE`` respectively, as mentioned above.
+.. code-block:: bash
+
+ # Pass the files generated by script.
+ <cmake build command> -DTFM_EXTRA_CONFIG_PATH=<output_path>/project_config.cmake \
+ -DPROJECT_CONFIG_HEADER_FILE=<output_path>/project_config.h
+
The TF-M build system has also integrated the tool.
-You only need to set ``USE_KCONFIG_TOOL`` to ``ON/TRUE/1`` and CMake will launch the GUI menuconfig
-for users to adjust configurations and automatically load the generated config files.
+You only need to set ``USE_KCONFIG_TOOL`` to ``ON/TRUE/1`` in commande line and CMake will launch
+the GUI menuconfig for users to adjust configurations and automatically load the generated config
+files.
.. note::
@@ -70,14 +95,11 @@
*****************
The Kconfig files
*****************
-The Kconfig files are the files written in the
+The Kconfig files are the files written by the
`Kconfig language <https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html#kconfig-language>`__
to describe config options.
-They also uses some Kconfiglib extensions such as ``osource`` and ``rsource`` so they can only work
-with the Kconfiglib.
-
-Component options are gathered together in a seperate menu ``TF-M component configs`` because these
-options are changed less frequently.
+They also uses some Kconfiglib extensions such as optional source ``osource`` and relative source ``rsource``
+so they can only work with the Kconfiglib.
--------------
diff --git a/docs/getting_started/tfm_getting_started.rst b/docs/getting_started/tfm_getting_started.rst
index dad3dc6..bd2934d 100644
--- a/docs/getting_started/tfm_getting_started.rst
+++ b/docs/getting_started/tfm_getting_started.rst
@@ -448,6 +448,7 @@
cbor2 --> python
click --> python
imgtool --> python
+ kconfiglib --> python
@enduml
.. rubric:: Next steps
diff --git a/lib/ext/psa_arch_tests/Kconfig b/lib/ext/psa_arch_tests/Kconfig
index a4e3c69..c707e2b 100644
--- a/lib/ext/psa_arch_tests/Kconfig
+++ b/lib/ext/psa_arch_tests/Kconfig
@@ -9,9 +9,7 @@
choice
prompt "PSA API Test Suite"
-
- config TEST_PSA_API_NONE
- bool "None"
+ optional
config TEST_PSA_API_IPC
bool "IPC"
@@ -51,7 +49,6 @@
config TEST_PSA_API
string
- default "" if TEST_PSA_API_NONE
default "IPC" if TEST_PSA_API_IPC
default "CRYPTO" if TEST_PSA_API_CRYPTO
default "INITIAL_ATTESTATION" if TEST_PSA_API_INITIAL_ATTESTATION
diff --git a/lib/ext/tf-m-tests/Kconfig b/lib/ext/tf-m-tests/Kconfig
index 30408e9..3d46e8c 100644
--- a/lib/ext/tf-m-tests/Kconfig
+++ b/lib/ext/tf-m-tests/Kconfig
@@ -64,7 +64,6 @@
imply TFM_PARTITION_CRYPTO
imply TFM_PARTITION_PLATFORM
-
config TEST_S_PLATFORM
bool "Platform"
default n
@@ -72,8 +71,11 @@
config TEST_S_FWU
bool "FWU"
- default n
+ depends on PLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT
imply TFM_PARTITION_FIRMWARE_UPDATE
+ imply TFM_PARTITION_CRYPTO
+ imply TFM_PARTITION_INTERNAL_TRUSTED_STORAGE
+ imply TFM_PARTITION_PLATFORM
config TEST_S_IPC
bool "IPC"
@@ -103,11 +105,15 @@
bool "t_cose"
default n
imply TFM_PARTITION_INITIAL_ATTESTATION
+ imply TFM_PARTITION_INTERNAL_TRUSTED_STORAGE
+ imply TFM_PARTITION_CRYPTO
config TEST_NS_QCBOR
bool "QCBOR"
default n
imply TFM_PARTITION_INITIAL_ATTESTATION
+ imply TFM_PARTITION_INTERNAL_TRUSTED_STORAGE
+ imply TFM_PARTITION_CRYPTO
config TEST_NS_CRYPTO
bool "Crypto"
@@ -136,8 +142,11 @@
config TEST_NS_FWU
bool "FWU"
- default n
+ depends on PLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT
imply TFM_PARTITION_FIRMWARE_UPDATE
+ imply TFM_PARTITION_CRYPTO
+ imply TFM_PARTITION_INTERNAL_TRUSTED_STORAGE
+ imply TFM_PARTITION_PLATFORM
config TEST_NS_MULTI_CORE
bool "Multi-core"
@@ -145,14 +154,10 @@
config TEST_NS_MANAGE_NSID
bool "NSID management"
- depends on TFM_NS_MANAGE_NSID
choice TEST_NS_IRQ
prompt "IRQ test type"
- default TEST_NS_NONE_IRQ
-
- config TEST_NS_NONE_IRQ
- bool "None IRQ test"
+ optional
config TEST_NS_FLIH_IRQ
bool "First-Level Interrupt Handling"
diff --git a/tools/kconfig/tfm_kconfig.py b/tools/kconfig/tfm_kconfig.py
index c18acc3..376b5df 100755
--- a/tools/kconfig/tfm_kconfig.py
+++ b/tools/kconfig/tfm_kconfig.py
@@ -179,8 +179,13 @@
def_config = ''
mtime_prv = 0
- if args.platform_path and os.path.exists(args.platform_path):
+ if args.platform_path:
platform_abs_path = os.path.abspath(args.platform_path)
+
+ if not os.path.exists(platform_abs_path):
+ logging.error('Platform path {} doesn\'t exist!'.format(platform_abs_path))
+ exit(1)
+
def_config = os.path.join(platform_abs_path, 'defconfig')
# Pass environment variable to Kconfig to load extra Kconfig file.
@@ -199,12 +204,10 @@
if os.path.exists(dot_config):
# Load .config which contains the previous configurations.
mtime_prv = os.stat(dot_config).st_mtime
- tfm_kconfig.load_config(dot_config)
- logging.info('Load configs from \'{}\''.format(dot_config))
+ logging.info(tfm_kconfig.load_config(dot_config))
elif os.path.exists(def_config):
# Load platform specific defconfig if exists.
- tfm_kconfig.load_config(def_config)
- logging.info('Load configs from \'{}\''.format(def_config))
+ logging.info(tfm_kconfig.load_config(def_config))
# UI options
if args.ui == 'tui':
@@ -214,7 +217,7 @@
else:
# Save .config if UI is not created.
# The previous .config will be saved as .config.old.
- tfm_kconfig.write_config(dot_config)
+ logging.info(tfm_kconfig.write_config(dot_config))
# Generate output files if .config has been changed.
if os.path.exists(dot_config) and os.stat(dot_config).st_mtime != mtime_prv:
diff --git a/tools/requirements.txt b/tools/requirements.txt
index 5c5609e..104889f 100644
--- a/tools/requirements.txt
+++ b/tools/requirements.txt
@@ -7,3 +7,4 @@
PyYAML
pyhsslms
ecdsa
+kconfiglib