Add local CI scripts for TFM 1.0 release

These scripts are based on current CI scripts
    iot-sw/tfm-ci-scripts with commit 5acf417

Major changes:
    Add configs to build all combinations for release required
    Codebase dynamically change when build PSA suite and OTP for parallel
    Build rules for PSA DEV API/PSA FF/ARCH TEST/OTP
    Build with parallel as much at it can be on the host
    Add test PSA ARCH on AN521 FVP for PSA DEV API
    Support PSA FF/DEV API tests on AN521 FVP
    Add “Minsizerel” type support for FVP tests
    Some hard-code or temporary changes that need to refine

Change-Id: I497b97e7cc57924295321259068b333a81a8f1a6
Signed-off-by: Karl Zhang <karl.zhang@arm.com>
diff --git a/build_helper/build_helper.py b/build_helper/build_helper.py
index 58957d7..9f57828 100755
--- a/build_helper/build_helper.py
+++ b/build_helper/build_helper.py
@@ -51,6 +51,7 @@
     """ Instantiate a build manager class and build all configurations """
 
     start_time = time.time()
+    print("relative_paths %s done \r\n" % relative_paths)
 
     bm = TFM_Build_Manager(tfm_dir=tfm_dir,
                            work_dir=build_dir,
@@ -83,6 +84,7 @@
     elif user_args.config:
         if user_args.config in _builtin_configs.keys():
             build_config = _builtin_configs[user_args.config.lower()]
+            print("main %s done \r\n" % build_config)
         else:
             print("Configuration %s is not defined in built-in configs" %
                   user_args.config)
@@ -94,9 +96,10 @@
     # Build everything
     build_status, build_report = build(user_args.tfm_dir,
                                        user_args.build_dir,
-                                       user_args.report,
+                                       #user_args.report,
+                                       "summary_" + user_args.config.lower() + ".json",
                                        build_config,
-                                       user_args.parallel_builds,
+                                       os.cpu_count(),
                                        user_args.thread_no,
                                        user_args.install,
                                        user_args.image_sizes,
diff --git a/build_helper/build_helper_configs.py b/build_helper/build_helper_configs.py
old mode 100644
new mode 100755
index 313fb27..9b4deae
--- a/build_helper/build_helper_configs.py
+++ b/build_helper/build_helper_configs.py
@@ -8,7 +8,7 @@
 
 __copyright__ = """
 /*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -33,6 +33,8 @@
     "sort_order": ["target_platform",
                    "compiler",
                    "proj_config",
+                   "psa_api_suit",
+                   "with_OTP",
                    "cmake_build_type",
                    "with_mcuboot"],
 
@@ -49,6 +51,17 @@
         "-DBL2=%(with_mcuboot)s "
         "%(codebase_root_dir)s"),
 
+    "config_template_psa_api": (
+        "cmake -G \"Unix Makefiles\" "
+        "-DPROJ_CONFIG=`"
+        "readlink -f %(codebase_root_dir)s/configs/%(proj_config)s.cmake` "
+        "-DTARGET_PLATFORM=%(target_platform)s "
+        "-DCOMPILER=%(compiler)s "
+        "-DCMAKE_BUILD_TYPE=%(cmake_build_type)s "
+#TODO: error when using this param
+#        "-DPSA_API_TEST_BUILD_PATH=%(_tbm_build_dir_)s "
+        "%(codebase_root_dir)s"),
+
     # A small subset of  string substitution params is allowed in commands.
     # tfm_build_manager will replace %(_tbm_build_dir_)s,  %(_tbm_code_dir_)s,
     # _tbm_target_platform_ with the  paths set when building
@@ -59,7 +72,7 @@
 
     # ALL commands will be executed for every build.
     # Other keys will append extra commands when matching target_platform
-    "build_cmds": {"all": ["cmake --build ./ -- -j 2 install"],
+    "build_cmds": {"all": ["cmake --build ./ -- install"],
                    "MUSCA_A": [("srec_cat "
                                 "%(_tbm_build_dir_)s/install/outputs/"
                                 "%(_tbm_target_platform_)s/mcuboot.bin "
@@ -106,10 +119,12 @@
 }
 
 # Configure build manager to build several combinations
-config_AN521 = {"seed_params": {
-                "target_platform": ["AN521"],
-                "compiler": ["GNUARM"],
+config_AN539 = {"seed_params": {
+                "target_platform": ["AN539"],
+                "compiler": ["ARMCLANG", "GNUARM"],
                 "proj_config": ["ConfigRegression",
+                                "ConfigRegressionIPC",
+                                "ConfigRegressionIPCTfmLevel2",
                                 "ConfigCoreIPC",
                                 "ConfigCoreIPCTfmLevel2",
                                 "ConfigDefault"],
@@ -123,12 +138,135 @@
                 "invalid": []
                 }
 
+# Configure build manager to build several combinations
+config_AN524 = {"seed_params": {
+                "target_platform": ["AN524"],
+                "compiler": ["ARMCLANG", "GNUARM"],
+                "proj_config": ["ConfigRegression",
+                                "ConfigRegressionIPC",
+                                "ConfigRegressionIPCTfmLevel2",
+                                "ConfigCoreIPC",
+                                "ConfigCoreIPCTfmLevel2",
+                                "ConfigDefault"],
+                "cmake_build_type": ["Debug", "Release"],
+                "with_mcuboot": [True, False],
+                },
+                "common_params": _common_tfm_builder_cfg,
+                # invalid configuations can be added as tuples of adjustable
+                # resolution "AN521" will reject all combinations for that
+                # platform while ("AN521", "GNUARM") will only reject GCC ones
+                "invalid": []
+                }
+
+# Configure build manager to build several combinations
+config_AN521 = {"seed_params": {
+                "target_platform": ["AN521"],
+                "compiler": ["ARMCLANG", "GNUARM"],
+                "proj_config": ["ConfigRegression",
+                                "ConfigRegressionIPC",
+                                "ConfigRegressionIPCTfmLevel2",
+                                "ConfigCoreIPC",
+                                "ConfigCoreIPCTfmLevel2",
+                                "ConfigDefault"],
+                "cmake_build_type": ["Debug", "Release"],
+                "with_mcuboot": [True, False],
+                },
+                "common_params": _common_tfm_builder_cfg,
+                # invalid configuations can be added as tuples of adjustable
+                # resolution "AN521" will reject all combinations for that
+                # platform while ("AN521", "GNUARM") will only reject GCC ones
+                "invalid": []
+                }
+
+# Configure build manager to build several combinations
+config_PSA_API = {"seed_params": {
+                "target_platform": ["AN521", "MUSCA_B1"],
+                "compiler": ["ARMCLANG", "GNUARM"],
+                "proj_config": ["ConfigPsaApiTest",
+                                "ConfigPsaApiTestIPC",
+                                "ConfigPsaApiTestIPCTfmLevel2"],
+                "psa_api_suit": ["CRYPTO",
+                                 "PROTECTED_STORAGE",
+                                 "INITIAL_ATTESTATION",
+                                 "INTERNAL_TRUSTED_STORAGE"],
+                "cmake_build_type": ["Debug", "Release", "Minsizerel"],
+                "with_mcuboot": [True],
+                },
+                "common_params": _common_tfm_builder_cfg,
+                # invalid configuations can be added as tuples of adjustable
+                # resolution "AN521" will reject all combinations for that
+                # platform while ("AN521", "GNUARM") will only reject GCC ones
+                "invalid": []
+                }
+
+# Configure build manager to build several combinations
+config_PSA_FF = {"seed_params": {
+                "target_platform": ["AN521", "MUSCA_B1"],
+                "compiler": ["ARMCLANG", "GNUARM"],
+                "proj_config": ["ConfigPsaApiTestIPC",
+                                "ConfigPsaApiTestIPCTfmLevel2"],
+                # Prefer to use "IPC" from compile command perspective
+                # But the name style is prefer "FF"
+                "psa_api_suit": ["FF"],
+                "cmake_build_type": ["Debug", "Release", "Minsizerel"],
+                "with_mcuboot": [True],
+                },
+                "common_params": _common_tfm_builder_cfg,
+                # invalid configuations can be added as tuples of adjustable
+                # resolution "AN521" will reject all combinations for that
+                # platform while ("AN521", "GNUARM") will only reject GCC ones
+                "invalid": []
+                }
+
+# Configure build manager to build several combinations
+config_PSA_API_OTP = {"seed_params": {
+                "target_platform": ["MUSCA_B1"],#
+                "compiler": ["ARMCLANG", "GNUARM"],
+                "proj_config": ["ConfigPsaApiTest",
+                                "ConfigPsaApiTestIPC",
+                                "ConfigPsaApiTestIPCTfmLevel2"],
+                "psa_api_suit": ["CRYPTO",
+                                 "PROTECTED_STORAGE",
+                                 "INITIAL_ATTESTATION",
+                                 "INTERNAL_TRUSTED_STORAGE"],
+                "with_OTP": ["OTP"],
+                "cmake_build_type": ["Debug", "Release", "Minsizerel"],#
+                "with_mcuboot": [True],
+                },
+                "common_params": _common_tfm_builder_cfg,
+                # invalid configuations can be added as tuples of adjustable
+                # resolution "AN521" will reject all combinations for that
+                # platform while ("AN521", "GNUARM") will only reject GCC ones
+                "invalid": []
+                }
+
+# Configure build manager to build several combinations
+config_PSA_FF_OTP = {"seed_params": {
+                "target_platform": ["MUSCA_B1"],
+                "compiler": ["ARMCLANG", "GNUARM"],
+                "proj_config": ["ConfigPsaApiTestIPC",
+                                "ConfigPsaApiTestIPCTfmLevel2"],
+                # Prefer to use "IPC" from compile command perspective
+                # But the name style is prefer "FF"
+                "psa_api_suit": ["FF"],
+                "with_OTP": ["OTP"],
+                "cmake_build_type": ["Debug", "Release", "Minsizerel"],
+                "with_mcuboot": [True],
+                },
+                "common_params": _common_tfm_builder_cfg,
+                # invalid configuations can be added as tuples of adjustable
+                # resolution "AN521" will reject all combinations for that
+                # platform while ("AN521", "GNUARM") will only reject GCC ones
+                "invalid": []
+                }
 
 # Configure build manager to build several combinations
 config_AN519 = {"seed_params": {
                 "target_platform": ["AN519"],
-                "compiler": ["GNUARM"],
+                "compiler": ["ARMCLANG", "GNUARM"],
                 "proj_config": ["ConfigRegression",
+                                "ConfigRegressionIPC",
+                                "ConfigRegressionIPCTfmLevel2",
                                 "ConfigCoreIPC",
                                 "ConfigCoreIPCTfmLevel2",
                                 "ConfigDefault"],
@@ -144,9 +282,11 @@
 
 config_IPC = {"seed_params": {
               "target_platform": ["AN521", "AN519", "MUSCA_A", "MUSCA_B1"],
-              "compiler": ["GNUARM"],
+              "compiler": ["ARMCLANG", "GNUARM"],
               "proj_config": ["ConfigCoreIPC",
-                              "ConfigCoreIPCTfmLevel2"],
+                              "ConfigCoreIPCTfmLevel2",
+                              "ConfigRegressionIPC",
+                              "ConfigRegressionIPCTfmLevel2"],
               "cmake_build_type": ["Debug", "Release"],
               "with_mcuboot": [True, False],
               },
@@ -159,9 +299,13 @@
 
 # Configure build manager to build the maximum number of configurations
 config_full = {"seed_params": {
-               "target_platform": ["AN521", "AN519", "MUSCA_A", "MUSCA_B1"],
-               "compiler": ["GNUARM"],
+               "target_platform": ["AN521", "AN519",
+                                   "MUSCA_A", "MUSCA_B1",
+                                   "AN524", "AN539"],
+               "compiler": ["ARMCLANG", "GNUARM"],
                "proj_config": ["ConfigRegression",
+                               "ConfigRegressionIPC",
+                               "ConfigRegressionIPCTfmLevel2",
                                "ConfigCoreIPC",
                                "ConfigCoreIPCTfmLevel2",
                                "ConfigDefault"],
@@ -176,10 +320,74 @@
                            ("MUSCA_B1", "*", "*", "*", False)]
                }
 
+# Configure build manager to build the maximum number of configurations
+config_tfm_test = {"seed_params": {
+                  "target_platform": ["AN521", "MUSCA_A", "MUSCA_B1", "MUSCA_S1"],
+                  "compiler": ["ARMCLANG", "GNUARM"],
+                  "proj_config": ["ConfigRegression",
+                                  "ConfigRegressionIPC",
+                                  "ConfigRegressionIPCTfmLevel2",
+                                  "ConfigCoreIPC",
+                                  "ConfigCoreIPCTfmLevel2",
+                                  "ConfigDefault"],
+                  "cmake_build_type": ["Debug", "Release", "Minsizerel"],
+                  "with_mcuboot": [True, False],
+                  },
+                  "common_params": _common_tfm_builder_cfg,
+                  # invalid configuations can be added as tuples of adjustable
+                  # resolution "AN521" will reject all combinations for that
+                  # platform while ("AN521", "GNUARM") will only reject GCC ones
+                  "invalid": [("MUSCA_A", "*", "*", "*", False),
+                              ("MUSCA_S1", "*", "*", "*", False),
+                              ("MUSCA_B1", "*", "*", "*", False)]
+                  }
+# Configure build manager to build the maximum number of configurations
+config_tfm_test2 = {"seed_params": {
+                  "target_platform": ["AN519", "AN524", "AN539", "SSE-200_AWS"],
+                  "compiler": ["ARMCLANG", "GNUARM"],
+                  "proj_config": ["ConfigRegression",
+                                  "ConfigRegressionIPC",
+                                  "ConfigRegressionIPCTfmLevel2",
+                                  "ConfigCoreIPC",
+                                  "ConfigCoreIPCTfmLevel2",
+                                  "ConfigDefault"],
+                  "cmake_build_type": ["Debug", "Release", "Minsizerel"],
+                  "with_mcuboot": [True, False],
+                  },
+                  "common_params": _common_tfm_builder_cfg,
+                  # invalid configuations can be added as tuples of adjustable
+                  # resolution "AN521" will reject all combinations for that
+                  # platform while ("AN521", "GNUARM") will only reject GCC ones
+                  "invalid": []
+                  }
+
+# Configure build manager to build the maximum number of configurations
+config_tfm_test_OTP = {"seed_params": {
+                  "target_platform": ["MUSCA_B1"],
+                  "compiler": ["ARMCLANG", "GNUARM"],
+                  "proj_config": ["ConfigRegression",
+                                  "ConfigRegressionIPC",
+                                  "ConfigRegressionIPCTfmLevel2",
+                                  "ConfigCoreIPC",
+                                  "ConfigCoreIPCTfmLevel2",
+                                  "ConfigDefault"],
+                  "with_OTP": ["OTP"],
+                  "cmake_build_type": ["Debug", "Release", "Minsizerel"],
+                  "with_mcuboot": [True],
+                  },
+                  "common_params": _common_tfm_builder_cfg,
+                  # invalid configuations can be added as tuples of adjustable
+                  # resolution "AN521" will reject all combinations for that
+                  # platform while ("AN521", "GNUARM") will only reject GCC ones
+                  "invalid": []
+                  }
+
 config_MUSCA_A = {"seed_params": {
                   "target_platform": ["MUSCA_A"],
-                  "compiler": ["GNUARM"],
+                  "compiler": ["ARMCLANG", "GNUARM"],
                   "proj_config": ["ConfigRegression",
+                                  "ConfigRegressionIPC",
+                                  "ConfigRegressionIPCTfmLevel2",
                                   "ConfigCoreIPC",
                                   "ConfigCoreIPCTfmLevel2",
                                   "ConfigDefault"],
@@ -195,8 +403,10 @@
 
 config_MUSCA_B1 = {"seed_params": {
                    "target_platform": ["MUSCA_B1"],
-                   "compiler": ["GNUARM"],
+                   "compiler": ["ARMCLANG", "GNUARM"],
                    "proj_config": ["ConfigRegression",
+                                   "ConfigRegressionIPC",
+                                   "ConfigRegressionIPCTfmLevel2",
                                    "ConfigCoreIPC",
                                    "ConfigCoreIPCTfmLevel2",
                                    "ConfigDefault"],
@@ -210,6 +420,69 @@
                    "invalid": [("MUSCA_B1", "*", "*", "*", False)]
                    }
 
+# Configure build manager to build the maximum number of configurations
+config_release = {"seed_params": {
+                  "target_platform": ["AN521", "AN519",
+                                      "MUSCA_A", "MUSCA_B1", "MUSCA_S1",
+                                      "AN524", "AN539"],
+                  "compiler": ["ARMCLANG", "GNUARM"],
+                  "proj_config": ["ConfigRegression",
+                                  "ConfigRegressionIPC",
+                                  "ConfigRegressionIPCTfmLevel2",
+                                  "ConfigCoreIPC",
+                                  "ConfigCoreIPCTfmLevel2",
+                                  "ConfigDefault"],
+                  "cmake_build_type": ["Debug", "Release", "MINSIZEREL"],
+                  "with_mcuboot": [True, False],
+                  },
+                  "common_params": _common_tfm_builder_cfg,
+                  # invalid configuations can be added as tuples of adjustable
+                  # resolution "AN521" will reject all combinations for that
+                  # platform while ("AN521", "GNUARM") will only reject GCC ones
+                  "invalid": [("MUSCA_A", "*", "*", "*", False),
+                              ("MUSCA_S1", "*", "*", "*", False),
+                              ("MUSCA_B1", "*", "*", "*", False)]
+                  }
+
+# Configure build manager to build several combinations
+config_AN521_PSA_API = {"seed_params": {
+                "target_platform": ["AN521", "AN519", "MUSCA_B1"],
+                "compiler": ["ARMCLANG", "GNUARM"],
+                "proj_config": ["ConfigPsaApiTest",
+                                "ConfigPsaApiTestIPC",
+                                "ConfigPsaApiTestIPCTfmLevel2"],
+                "psa_api_suit": ["CRYPTO",
+                                 "PROTECTED_STORAGE",
+                                 "INITIAL_ATTESTATION",
+                                 "INTERNAL_TRUSTED_STORAGE",
+                                 "IPC"],
+                "cmake_build_type": ["Debug", "Release", "MINSIZEREL"],
+                "with_mcuboot": [True],
+                },
+                "common_params": _common_tfm_builder_cfg,
+                # invalid configuations can be added as tuples of adjustable
+                # resolution "AN521" will reject all combinations for that
+                # platform while ("AN521", "GNUARM") will only reject GCC ones
+                "invalid": [("*", "*", "*", "IPC", "*", "*")]
+                }
+
+# Configure build manager to build several combinations
+config_AN521_PSA_IPC = {"seed_params": {
+                "target_platform": ["AN521", "AN519", "MUSCA_B1"],
+                "compiler": ["ARMCLANG", "GNUARM"],
+                "proj_config": ["ConfigPsaApiTestIPC",
+                                "ConfigPsaApiTestIPCTfmLevel2"],
+                "psa_api_suit": ["IPC"],
+                "cmake_build_type": ["Debug", "Release", "MINSIZEREL"],
+                "with_mcuboot": [True],
+                },
+                "common_params": _common_tfm_builder_cfg,
+                # invalid configuations can be added as tuples of adjustable
+                # resolution "AN521" will reject all combinations for that
+                # platform while ("AN521", "GNUARM") will only reject GCC ones
+                "invalid": []
+                }
+
 # Configruation used for document building
 config_doxygen = {"common_params": {
                   "config_type": "tf-m_documents",
@@ -233,7 +506,7 @@
                   "invalid": []
                   }
 
-# Configruation used in testing
+# Configuration used in testing
 config_debug = {"seed_params": {
                 "target_platform": ["AN521"],
                 "compiler": ["ARMCLANG"],
@@ -242,7 +515,7 @@
                 "with_mcuboot": [True],
                 },
                 "common_params": _common_tfm_builder_cfg,
-                # invalid configuations can be added as tuples of adjustable
+                # invalid configurations can be added as tuples of adjustable
                 # resolution "AN521" will reject all combinations for that
                 # platform while ("AN521", "GNUARM") will only reject GCC ones
                 "invalid": [("*", "GNUARM", "*", "*", False),
@@ -267,7 +540,17 @@
     ],
 }
 
-_builtin_configs = {"full": config_full,
+_builtin_configs = {
+                    "tfm_test": config_tfm_test,
+                    "tfm_test2": config_tfm_test2,
+                    "tfm_test_otp": config_tfm_test_OTP,
+                    "psa_api": config_PSA_API,
+                    "psa_api_otp": config_PSA_API_OTP,
+                    "psa_ff": config_PSA_FF,
+                    "psa_ff_otp": config_PSA_FF_OTP,
+                    "full": config_full,
+                    "an539": config_AN539,
+                    "an524": config_AN524,
                     "an521": config_AN521,
                     "an519": config_AN519,
                     "musca_a": config_MUSCA_A,
@@ -275,6 +558,9 @@
                     "ipc": config_IPC,
                     "doxygen": config_doxygen,
                     "debug": config_debug,
+                    "release": config_release,
+                    "an521_psa_api": config_AN521_PSA_API,
+                    "an521_psa_ipc": config_AN521_PSA_IPC,
                     "ci": config_ci}
 
 if __name__ == '__main__':
diff --git a/fastmodel_dispatcher/AN521.py b/fastmodel_dispatcher/AN521.py
index 8953aa1..533ae5a 100644
--- a/fastmodel_dispatcher/AN521.py
+++ b/fastmodel_dispatcher/AN521.py
@@ -32,7 +32,10 @@
 
     from tfm_ci_pylib.fastmodel_wrapper import \
         template_default_config, template_regression_config, \
-        template_coreipc_config, template_coreipctfmlevel2_config
+        template_coreipc_config, template_coreipctfmlevel2_config, \
+        template_regressionipc_config, template_regressionipctfmlevel2_config, \
+        template_psaapitestipctfmlevel2_config, \
+        template_psaapitestipc_config, template_psaapitest_config
 except ImportError:
     dir_path = os.path.dirname(os.path.realpath(__file__))
     sys.path.append(os.path.join(dir_path, "../"))
@@ -40,7 +43,10 @@
     from tfm_ci_pylib.fastmodel_wrapper import config_variant
     from tfm_ci_pylib.fastmodel_wrapper import \
         template_default_config, template_regression_config, \
-        template_coreipc_config, template_coreipctfmlevel2_config
+        template_coreipc_config, template_coreipctfmlevel2_config, \
+        template_regressionipc_config, template_regressionipctfmlevel2_config, \
+        template_psaapitestipctfmlevel2_config, \
+        template_psaapitestipc_config, template_psaapitest_config
 
 # =====================  AN521 Configuration Classes ======================
 # Configurations will be dynamically defined
@@ -111,6 +117,37 @@
 class an521_gnuarm_configdefault_release_nobl2(template_default_config):
     pass
 
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configdefault_minsizerel_bl2(template_default_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configdefault_minsizerel_bl2(template_default_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_armclang_configdefault_minsizerel_nobl2(template_default_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_gnuarm_configdefault_minsizerel_nobl2(template_default_config):
+    pass
+
 # =====================  Regressions Config ======================
 
 @config_variant(platform="AN521",
@@ -177,6 +214,233 @@
 class an521_gnuarm_configregression_release_nobl2(template_regression_config):
     pass
 
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configregression_minsizerel_bl2(template_regression_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configregression_minsizerel_bl2(template_regression_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_armclang_configregression_minsizerel_nobl2(template_regression_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_gnuarm_configregression_minsizerel_nobl2(template_regression_config):
+    pass
+
+# =====================  RegressionIPC Config ======================
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configregressionipc_debug_bl2(template_regressionipc_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configregressionipc_debug_bl2(template_regressionipc_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Debug",
+                bootloader="NOBL2")
+class an521_armclang_configregressionipc_debug_nobl2(template_regressionipc_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Debug",
+                bootloader="NOBL2")
+class an521_gnuarm_configregressionipc_debug_nobl2(template_regressionipc_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configregressionipc_release_bl2(template_regressionipc_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configregressionipc_release_bl2(template_regressionipc_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Release",
+                bootloader="NOBL2")
+class an521_armclang_configregressionipc_release_nobl2(
+        template_regressionipc_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Release",
+                bootloader="NOBL2")
+class an521_gnuarm_configregressionipc_release_nobl2(template_regressionipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configregressionipc_minsizerel_bl2(template_regressionipc_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configregressionipc_minsizerel_bl2(template_regressionipc_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_armclang_configregressionipc_minsizerel_nobl2(
+        template_regressionipc_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_gnuarm_configregressionipc_minsizerel_nobl2(template_regressionipc_config):
+    pass
+
+# =====================  RegressionIPCTfmLevel2 Config ======================
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configregressionipctfmlevel2_debug_bl2(template_regressionipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configregressionipctfmlevel2_debug_bl2(template_regressionipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Debug",
+                bootloader="NOBL2")
+class an521_armclang_configregressionipctfmlevel2_debug_nobl2(template_regressionipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Debug",
+                bootloader="NOBL2")
+class an521_gnuarm_configregressionipctfmlevel2_debug_nobl2(template_regressionipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configregressionipctfmlevel2_release_bl2(template_regressionipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configregressionipctfmlevel2_release_bl2(template_regressionipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Release",
+                bootloader="NOBL2")
+class an521_armclang_configregressionipctfmlevel2_release_nobl2(
+        template_regressionipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Release",
+                bootloader="NOBL2")
+class an521_gnuarm_configregressionipctfmlevel2_release_nobl2(template_regressionipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configregressionipctfmlevel2_minsizerel_bl2(template_regressionipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configregressionipctfmlevel2_minsizerel_bl2(template_regressionipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_armclang_configregressionipctfmlevel2_minsizerel_nobl2(
+        template_regressionipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_gnuarm_configregressionipctfmlevel2_minsizerel_nobl2(template_regressionipctfmlevel2_config):
+    pass
+
 # =====================  CoreIPC Config ======================
 
 
@@ -247,6 +511,36 @@
 class an521_gnuarm_configcoreipc_release_nobl2(template_coreipc_config):
     pass
 
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configcoreipc_minsizerel_bl2(template_coreipc_config):
+
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_armclang_configcoreipc_minsizerel_nobl2(template_coreipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configcoreipc_minsizerel_bl2(template_coreipc_config):
+
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_gnuarm_configcoreipc_minsizerel_nobl2(template_coreipc_config):
+    pass
+
 # =====================  CoreIPCTfmLevel2 Config ======================
 
 
@@ -313,6 +607,714 @@
 class an521_gnuarm_configcoreipctfmlevel2_release_nobl2(template_coreipctfmlevel2_config):
     pass
 
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configcoreipctfmlevel2_minsizerel_bl2(template_coreipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_armclang_configcoreipctfmlevel2_minsizerel_nobl2(template_coreipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configcoreipctfmlevel2_minsizerel_bl2(template_coreipctfmlevel2_config):
+    pass
+
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                build_type="Minsizerel",
+                bootloader="NOBL2")
+class an521_gnuarm_configcoreipctfmlevel2_minsizerel_nobl2(template_coreipctfmlevel2_config):
+    pass
+
+# =====================  ConfigPsaApiTestIPCTfmLevel2 Config ======================
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Crypto",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_crypto_debug_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Crypto",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_crypto_release_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Crypto",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_crypto_minsizerel_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="PS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_ps_debug_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="PS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_ps_release_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="PS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_ps_minsizerel_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="ITS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_its_debug_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="ITS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_its_release_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="ITS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_its_minsizerel_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Attest",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_attest_debug_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Attest",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_attest_release_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Attest",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_attest_minsizerel_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Crypto",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_crypto_debug_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Crypto",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_crypto_release_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Crypto",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_crypto_minsizerel_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="PS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_ps_debug_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="PS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_ps_release_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="PS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_ps_minsizerel_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="ITS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_its_debug_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="ITS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_its_release_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="ITS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_its_minsizerel_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Attest",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_attest_debug_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Attest",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_attest_release_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Attest",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_attest_minsizerel_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="FF",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_ff_debug_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="FF",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_ff_release_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="FF",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipctfmlevel2_ff_minsizerel_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="FF",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_ff_debug_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="FF",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_ff_release_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="FF",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipctfmlevel2_ff_minsizerel_bl2(template_psaapitestipctfmlevel2_config):
+    pass
+
+# =====================  ConfigPsaApiTestIPC Config ======================
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Crypto",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_crypto_debug_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Crypto",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_crypto_release_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Crypto",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_crypto_minsizerel_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="PS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_ps_debug_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="PS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_ps_release_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="PS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_ps_minsizerel_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="ITS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_its_debug_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="ITS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_its_release_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="ITS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_its_minsizerel_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Attest",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_attest_debug_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Attest",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_attest_release_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Attest",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_attest_minsizerel_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Crypto",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_crypto_debug_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Crypto",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_crypto_release_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Crypto",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_crypto_minsizerel_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="PS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_ps_debug_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="PS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_ps_release_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="PS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_ps_minsizerel_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="ITS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_its_debug_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="ITS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_its_release_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="ITS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_its_minsizerel_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Attest",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_attest_debug_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Attest",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_attest_release_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Attest",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_attest_minsizerel_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="FF",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_ff_debug_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="FF",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_ff_release_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="FF",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitestipc_ff_minsizerel_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="FF",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_ff_debug_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="FF",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_ff_release_bl2(template_psaapitestipc_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="FF",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitestipc_ff_minsizerel_bl2(template_psaapitestipc_config):
+    pass
+
+# =====================  ConfigPsaApiTest Config ======================
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Crypto",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_crypto_debug_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Crypto",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_crypto_release_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Crypto",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_crypto_minsizerel_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="PS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_ps_debug_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="PS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_ps_release_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="PS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_ps_minsizerel_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="ITS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_its_debug_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="ITS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_its_release_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="ITS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_its_minsizerel_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Attest",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_attest_debug_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Attest",
+                build_type="Release",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_attest_release_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="GNUARM",
+                psa_suite="Attest",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_gnuarm_configpsaapitest_attest_minsizerel_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Crypto",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_crypto_debug_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Crypto",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_crypto_release_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Crypto",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_crypto_minsizerel_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="PS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_ps_debug_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="PS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_ps_release_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="PS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_ps_minsizerel_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="ITS",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_its_debug_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="ITS",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_its_release_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="ITS",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_its_minsizerel_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Attest",
+                build_type="Debug",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_attest_debug_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Attest",
+                build_type="Release",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_attest_release_bl2(template_psaapitest_config):
+    pass
+
+@config_variant(platform="AN521",
+                compiler="ARMCLANG",
+                psa_suite="Attest",
+                build_type="Minsizerel",
+                bootloader="BL2")
+class an521_armclang_configpsaapitest_attest_minsizerel_bl2(template_psaapitest_config):
+    pass
+
 AN521 = FastmodelConfigMap(globals(), "AN521")
 
 if __name__ == "__main__":
diff --git a/fastmodel_dispatcher/fastmodel_dispatcher.py b/fastmodel_dispatcher/fastmodel_dispatcher.py
index 8c12dae..b6af86f 100644
--- a/fastmodel_dispatcher/fastmodel_dispatcher.py
+++ b/fastmodel_dispatcher/fastmodel_dispatcher.py
@@ -81,10 +81,12 @@
         # build and test configs share common key name enties
         config_list = list(map(str.lower,
                                (map(str, build_report["report"].keys()))))
+        print("zss config_list %s" % config_list)
 
         # Only choose the tests that have been defined in the map
         test_config_list = [n for n in fvp_config_map.list()
                             if n in config_list]
+        print("zss test_config_list original %s" % test_config_list)
 
         # Use the Build manager to calcuate the rejection list in the same
         # manner.
@@ -117,13 +119,14 @@
     else:
         pass
 
-    print("Working on Test list: \n%s" % "\n".join(sorted(test_config_list)))
-
+#    print("Working on Test list: \n%s" % "\n".join(sorted(test_config_list)))
+ 
     if user_args.p_command:
 
         for test_cfg in test_config_list:
 
             test_cfg_obj = fvp_config_map.get_config_object(test_cfg)
+
             _tmp_cfg = FastmodelWrapper(fvp_cfg=test_cfg_obj.get_config())
 
             print("\nCommand line:")
@@ -135,12 +138,17 @@
     # Run tests
     rep = []
     test_count = 0
+#    print("zss print_list list")
+#    fvp_config_map.print_list()
+    print("zss test_config_list", test_config_list)
     for test_cfg in test_config_list:
 
         # Check if the config hardcoded binary path is same as the one
         # in the build report. If not update the config
         test_cfg_obj = fvp_config_map.get_config_object(test_cfg)
+        print("+++test_cfg_obj %s\r\n %s\r\ntest_cfg %s" % (test_cfg_obj, test_cfg_obj.get_config(), test_cfg))
 
+        print("---- test_cfg_obj.get_config()", test_cfg_obj.get_config())
         rep.append(FastmodelWrapper(
                    fvp_cfg=test_cfg_obj.get_config())
                    .start().block_wait().test().save_report().get_report())
@@ -214,7 +222,7 @@
     parser.add_argument("-p", "--print-command",
                         dest="p_command",
                         action="store_true",
-                        help="Print the FPV launch command to console & exit")
+                        help="Print the FVP launch command to console & exit")
     return parser.parse_args()
 
 
diff --git a/tfm_ci_pylib/fastmodel_wrapper/__init__.py b/tfm_ci_pylib/fastmodel_wrapper/__init__.py
index d59ebcc..a1fca97 100644
--- a/tfm_ci_pylib/fastmodel_wrapper/__init__.py
+++ b/tfm_ci_pylib/fastmodel_wrapper/__init__.py
@@ -18,4 +18,6 @@
 
 from .config_templates import template_default_config, \
     template_regression_config, template_coreipc_config, \
-    template_coreipctfmlevel2_config
+    template_coreipctfmlevel2_config, template_regressionipc_config, \
+    template_regressionipctfmlevel2_config, template_psaapitestipctfmlevel2_config, \
+    template_psaapitestipc_config, template_psaapitest_config
diff --git a/tfm_ci_pylib/fastmodel_wrapper/config_templates.py b/tfm_ci_pylib/fastmodel_wrapper/config_templates.py
index 2f97652..fea5b7c 100644
--- a/tfm_ci_pylib/fastmodel_wrapper/config_templates.py
+++ b/tfm_ci_pylib/fastmodel_wrapper/config_templates.py
@@ -44,6 +44,7 @@
         "config": "%(config)s",
         "platform": "%(platform)s",
         "compiler": "%(compiler)s",
+        "psa_suite": "%(psa_suite)s",
         "build_type": "%(build_type)s",
         "bootloader": "%(bootloader)s"
     }
@@ -228,3 +229,108 @@
     # Testing will stop if string is reached
     _cfg["test_end_string"] = "Secure image initializing"
     _cfg["simlimit"] = "1200"
+
+class template_psaapitestipctfmlevel2_config(template_cfg):
+    """ Will automatically populate the required information for tfm
+    coreipc tfmlevel2 configuration testing. User still needs to set the
+    buildpath, platform, compiler variants """
+
+    _cfg = deepcopy(template_cfg._cfg)
+
+    _vdict = deepcopy(template_cfg._vdict)
+
+    # Set defaults across all variants
+    _vdict["build_path"] = "build-ci-all"
+
+    _vdict["app_bin_path"] = "install/outputs/fvp"
+    _vdict["data_bin_path"] = "install/outputs/fvp"
+
+    _vdict["variant_name_tpl"] = "%(platform)s_%(compiler)s_%(config)s_" + \
+        "%(psa_suite)s_%(build_type)s_%(bootloader)s"
+
+    # Mofify the %(config)s parameter of the template
+    _vdict["config"] = "ConfigPsaApiTestIPCTfmLevel2"
+    _cfg["terminal_log"] = _cfg["terminal_log"] % _vdict
+
+    # System supports two types of matching with
+    # test_case_id and result match group and only test_case_id
+    _cfg["test_rex"] = (r'Entering standby'
+                        )
+
+    # test_case_id capture group Should match test_cases entries
+    _cfg["test_cases"] = [
+        'Secure image initializing!',
+    ]
+    # Testing will stop if string is reached
+    _cfg["test_end_string"] = "Entering standby.."
+    _cfg["simlimit"] = "1200"
+
+class template_psaapitestipc_config(template_cfg):
+    """ Will automatically populate the required information for tfm
+    coreipc tfmlevel2 configuration testing. User still needs to set the
+    buildpath, platform, compiler variants """
+
+    _cfg = deepcopy(template_cfg._cfg)
+
+    _vdict = deepcopy(template_cfg._vdict)
+
+    # Set defaults across all variants
+    _vdict["build_path"] = "build-ci-all"
+
+    _vdict["app_bin_path"] = "install/outputs/fvp"
+    _vdict["data_bin_path"] = "install/outputs/fvp"
+
+    _vdict["variant_name_tpl"] = "%(platform)s_%(compiler)s_%(config)s_" + \
+        "%(psa_suite)s_%(build_type)s_%(bootloader)s"
+
+    # Mofify the %(config)s parameter of the template
+    _vdict["config"] = "ConfigPsaApiTestIPC"
+    _cfg["terminal_log"] = _cfg["terminal_log"] % _vdict
+
+    # System supports two types of matching with
+    # test_case_id and result match group and only test_case_id
+    _cfg["test_rex"] = (r'Entering standby'
+                        )
+
+    # test_case_id capture group Should match test_cases entries
+    _cfg["test_cases"] = [
+        'Secure image initializing!',
+    ]
+    # Testing will stop if string is reached
+    _cfg["test_end_string"] = "Entering standby.."
+    _cfg["simlimit"] = "1200"
+
+class template_psaapitest_config(template_cfg):
+    """ Will automatically populate the required information for tfm
+    coreipc tfmlevel2 configuration testing. User still needs to set the
+    buildpath, platform, compiler variants """
+
+    _cfg = deepcopy(template_cfg._cfg)
+
+    _vdict = deepcopy(template_cfg._vdict)
+
+    # Set defaults across all variants
+    _vdict["build_path"] = "build-ci-all"
+
+    _vdict["app_bin_path"] = "install/outputs/fvp"
+    _vdict["data_bin_path"] = "install/outputs/fvp"
+
+    _vdict["variant_name_tpl"] = "%(platform)s_%(compiler)s_%(config)s_" + \
+        "%(psa_suite)s_%(build_type)s_%(bootloader)s"
+
+    # Mofify the %(config)s parameter of the template
+    _vdict["config"] = "ConfigPsaApiTest"
+    _cfg["terminal_log"] = _cfg["terminal_log"] % _vdict
+
+    # System supports two types of matching with
+    # test_case_id and result match group and only test_case_id
+    _cfg["test_rex"] = (r'Entering standby'
+                        )
+
+    # test_case_id capture group Should match test_cases entries
+    _cfg["test_cases"] = [
+        'Secure image initializing!',
+    ]
+    # Testing will stop if string is reached
+    _cfg["test_end_string"] = "Entering standby.."
+    _cfg["simlimit"] = "1200"
diff --git a/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper.py b/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper.py
index 7566c2e..d49cd6c 100755
--- a/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper.py
+++ b/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper.py
@@ -257,6 +257,7 @@
 
         # Convert to list
         cmd = self.compile_cmd().split(" ")
+        print("fvp cmd ", self.compile_cmd())
 
         # Run it as subproccess
         self.fvp_proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=False)
@@ -286,9 +287,10 @@
                     queue.put(line)
 
                 # If the text end string is found terminate
-                if self.test_end_string in str(line):
+                if str(line).find(self.test_end_string) > 0:
 
                     queue.put("Found End String \"%s\"" % self.test_end_string)
+                    print("Found End String \"%s\"" % self.test_end_string)
                     self.test_complete = True
                     self.stop()
                     break
@@ -344,7 +346,7 @@
             print("Could not find all binaries from %s" % ", ".join(bin_list))
             print("Missing Files:", ", ".join(find_missing_files(bin_list)))
             sys.exit(1)
-
+        self.show_cmd()
         self.pids.append(self.run_fpv())
         self.pids.append(self.run_monitor())
         print("Spawned Proccesses with PID %s" % repr(self.pids)[1:-1])
diff --git a/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper_config.py b/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper_config.py
index 0c2f60a..2180620 100644
--- a/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper_config.py
+++ b/tfm_ci_pylib/fastmodel_wrapper/fastmodel_wrapper_config.py
@@ -200,6 +200,25 @@
                 _cfg["application"] = _cfg["application"] % _vdict
                 _cfg["data"] = _cfg["data"] % _vdict
 
+                if _vdict["psa_suite"] == "FF":
+                    print("TfmFastModelConfig override:")
+                    _cfg["parameters"] = [
+                        "fvp_mps2.platform_type=2",
+                        "cpu0.baseline=0",
+                        "cpu0.INITVTOR_S=0x10080400",
+                        "cpu0.semihosting-enable=0",
+                        "fvp_mps2.DISABLE_GATING=0",
+                        "fvp_mps2.telnetterminal0.start_telnet=0",
+                        "fvp_mps2.telnetterminal1.start_telnet=0",
+                        "fvp_mps2.telnetterminal2.start_telnet=0",
+                        "fvp_mps2.telnetterminal0.quiet=1",
+                        "fvp_mps2.telnetterminal1.quiet=1",
+                        "fvp_mps2.telnetterminal2.quiet=1",
+                        "fvp_mps2.UART2.out_file=$TERM_FILE",
+                        "fvp_mps2.UART2.unbuffered_output=1",
+                        "fvp_mps2.UART0.shutdown_on_eot=1",
+                        "fvp_mps2.mps2_visualisation.disable-visualisation=1"]
+
                 _name = cls._name % _vdict
 
         return TfmFastModelConfig
diff --git a/tfm_ci_pylib/tfm_build_manager.py b/tfm_ci_pylib/tfm_build_manager.py
index 4ce848a..56bf469 100644
--- a/tfm_ci_pylib/tfm_build_manager.py
+++ b/tfm_ci_pylib/tfm_build_manager.py
@@ -22,6 +22,7 @@
 
 import os
 import sys
+from .utils import *
 from time import time
 from copy import deepcopy
 from .utils import gen_cfg_combinations, list_chunks, load_json,\
@@ -60,6 +61,8 @@
 
         self._tbm_tfm_dir = os.path.abspath(os.path.expanduser(tfm_dir))
 
+        print("bm param tfm_dir %s" % tfm_dir)
+        print("bm %s %s %s" % (work_dir, cfg_dict, self._tbm_work_dir))
         # Internal flag to tag simple (non combination formatted configs)
         self.simple_config = False
         self._tbm_report = report
@@ -67,6 +70,8 @@
         self._tbm_cfg = self.load_config(cfg_dict, self._tbm_work_dir)
         self._tbm_build_cfg, \
             self.tbm_common_cfg = self.parse_config(self._tbm_cfg)
+        self._tfb_code_base_updated = False
+        self._tfb_log_f = "CodeBasePrepare.log"
 
         super(TFM_Build_Manager, self).__init__(name="TFM_Build_Manager")
 
@@ -124,6 +129,66 @@
                                 "of type %s" % (key, config[key]))
         return config
 
+    def pre_build(self, build_cfg):
+        print("pre_build start %s \r\nself._tfb_cfg %s\r\n" %
+                (self, build_cfg))
+
+        try:
+            if self._tfb_code_base_updated:
+                print("Code base has been updated")
+                return True
+
+            self._tfb_code_base_updated = True
+
+            if "build_psa_api" in build_cfg:
+                # FF IPC build needs repo manifest update for TFM and PSA arch test
+                if "build_ff_ipc" in build_cfg:
+                    print("Checkout to FF IPC code base")
+                    os.chdir(build_cfg["codebase_root_dir"] + "/../psa-arch-tests/api-tests")
+                    _api_test_manifest = "git checkout . ; python3 tools/scripts/manifest_update.py"
+                    if subprocess_log(_api_test_manifest,
+                                      self._tfb_log_f,
+                                      append=True,
+                                      prefix=_api_test_manifest):
+
+                        raise Exception("Python Failed please check log: %s" %
+                                        self._tfb_log_f)
+
+                    _api_test_manifest_tfm = "python3 tools/tfm_parse_manifest_list.py -m tools/tfm_psa_ff_test_manifest_list.yaml append"
+                    os.chdir(build_cfg["codebase_root_dir"])
+                    if subprocess_log(_api_test_manifest_tfm,
+                                      self._tfb_log_f,
+                                      append=True,
+                                      prefix=_api_test_manifest_tfm):
+
+                        raise Exception("Python TFM Failed please check log: %s" %
+                                        self._tfb_log_f)
+                    return True
+
+            print("Checkout to default code base")
+            os.chdir(build_cfg["codebase_root_dir"] + "/../psa-arch-tests/api-tests")
+            _api_test_manifest = "git checkout ."
+            if subprocess_log(_api_test_manifest,
+                              self._tfb_log_f,
+                              append=True,
+                              prefix=_api_test_manifest):
+
+                raise Exception("Python Failed please check log: %s" %
+                                self._tfb_log_f)
+
+            _api_test_manifest_tfm = "python3 tools/tfm_parse_manifest_list.py"
+            os.chdir(build_cfg["codebase_root_dir"])
+            if subprocess_log(_api_test_manifest_tfm,
+                              self._tfb_log_f,
+                              append=True,
+                              prefix=_api_test_manifest_tfm):
+
+                raise Exception("Python TFM Failed please check log: %s" %
+                                self._tfb_log_f)
+        finally:
+            print("python pass after builder prepare")
+            os.chdir(build_cfg["codebase_root_dir"] + "/../")
+
     def task_exec(self):
         """ Create a build pool and execute them in parallel """
 
@@ -169,7 +234,8 @@
         # When a seed pool is provided iterate through the entries
         # and update platform spefific parameters
         elif len(self._tbm_build_cfg):
-
+            print("\r\n_tbm_build_cfg %s\r\n tbm_common_cfg %s\r\n" \
+             % (self._tbm_build_cfg, self.tbm_common_cfg))
             for name, i in self._tbm_build_cfg.items():
                 # Do not modify the original config
                 build_cfg = deepcopy(self.tbm_common_cfg)
@@ -193,11 +259,62 @@
 
                 # Merge the two dictionaries since the template may contain
                 # fixed and combinations seed parameters
-                cmd0 = build_cfg["config_template"] % \
-                    dict(dict(i._asdict()), **build_cfg)
+                if i.proj_config.startswith("ConfigPsaApiTest"):
+                    #PSA API tests only
+                    #TODO i._asdict()["tfm_build_dir"] = self._tbm_work_dir
+                    cmd0 = build_cfg["config_template_psa_api"] % \
+                        {**dict(i._asdict()), **build_cfg}
+                    cmd0 += " -DPSA_API_TEST_BUILD_PATH=" + self._tbm_work_dir + \
+                            "/" + name + "/BUILD"
 
-                # Prepend configuration commoand as the first cmd
+                    if i.psa_api_suit == "FF":
+                        cmd0 += " -DPSA_API_TEST_IPC=ON"
+                        cmd2 = "cmake " + build_cfg["codebase_root_dir"] + "/../psa-arch-tests/api-tests/ " + \
+                            "-G\"Unix Makefiles\" -DTARGET=tgt_ff_tfm_" + \
+                            i.target_platform.lower() +" -DCPU_ARCH=armv8m_ml -DTOOLCHAIN=" + \
+                            i.compiler + " -DSUITE=IPC -DPSA_INCLUDE_PATHS=\"" + \
+                            build_cfg["codebase_root_dir"] + "/interface/include/"
+
+                        cmd2 += ";" + build_cfg["codebase_root_dir"] + \
+                            "/../psa-arch-tests/api-tests/platform/manifests\"" + \
+                            " -DINCLUDE_PANIC_TESTS=1 -DPLATFORM_PSA_ISOLATION_LEVEL=" + \
+                            (("2") if i.proj_config.find("TfmLevel2") > 0 else "1") + \
+                            " -DSP_HEAP_MEM_SUPP=0"
+                        if i.target_platform == "MUSCA_B1":
+                            cmd0 += " -DSST_RAM_FS=ON"
+                        build_cfg["build_ff_ipc"] = "IPC"
+                    else:
+                        cmd0 += " -DPSA_API_TEST_" + i.psa_api_suit + "=ON"
+                        cmd2 = "cmake " + build_cfg["codebase_root_dir"] + "/../psa-arch-tests/api-tests/ " + \
+                            "-G\"Unix Makefiles\" -DTARGET=tgt_dev_apis_tfm_" + \
+                            i.target_platform.lower() +" -DCPU_ARCH=armv8m_ml -DTOOLCHAIN=" + \
+                            i.compiler + " -DSUITE=" + i.psa_api_suit +" -DPSA_INCLUDE_PATHS=\"" + \
+                            build_cfg["codebase_root_dir"] + "/interface/include/\""
+
+                    cmd2 += " -DCMAKE_BUILD_TYPE=" + i.cmake_build_type
+
+                    cmd3 = "cmake --build ."
+                    build_cfg["build_psa_api"] = cmd2 + " ; " + cmd3
+
+                else:
+                    cmd0 = build_cfg["config_template"] % \
+                        {**dict(i._asdict()), **build_cfg}
+
+                try:
+                    if i.__str__().find("with_OTP") > 0:
+                        cmd0 += " -DCRYPTO_HW_ACCELERATOR_OTP_STATE=ENABLED"
+                    else:
+                        build_cfg["build_cmds"][0] += " -j 2"
+                    if cmd0.find("SST_RAM_FS=ON") < 0 and i.target_platform == "MUSCA_B1":
+                        cmd0 += " -DSST_RAM_FS=OFF -DITS_RAM_FS=OFF"
+                except Exception as E:
+                    pass
+
+                # Prepend configuration commoand as the first cmd [cmd1] + [cmd2] + [cmd3] +
                 build_cfg["build_cmds"] = [cmd0] + build_cfg["build_cmds"]
+                print("cmd0 %s\r\n" % (build_cfg["build_cmds"]))
+                if "build_psa_api" in build_cfg:
+                    print("cmd build_psa_api %s\r\n" % build_cfg["build_psa_api"])
 
                 # Set the overrid params
                 over_dict = {"_tbm_build_dir_": os.path.join(
@@ -211,7 +328,7 @@
                 build_cfg = self.override_tbm_cfg_params(build_cfg,
                                                          over_params,
                                                          **over_dict)
-
+                self.pre_build(build_cfg)
                 # Overrides path in expected artefacts
                 print("Loading config %s" % name)
 
@@ -381,7 +498,7 @@
             fl = ([k for k, v in full_rep.items() if v['status'] == 'Failed'])
             ps = ([k for k, v in full_rep.items() if v['status'] == 'Success'])
         except Exception as E:
-            print("No report generated")
+            print("No report generated", E)
             return
         if fl:
             print_test(t_list=fl, status="failed", tname="Builds")
@@ -401,6 +518,7 @@
             # optional parameters.
             tags = [n for n in static_config["sort_order"]
                     if n in seed_config.keys()]
+            print("!!!!!!!!!!!gen list %s\r\n" % tags)
 
             data = []
             for key in tags:
@@ -421,7 +539,12 @@
 
             # Replace bollean vaiables with more BL2/NOBL2 and use it as"
             # configuration name.
-            ret_cfg[i_str.replace("True", "BL2").replace("False", "NOBL2")] = i
+            i_str = i_str.replace("True", "BL2").replace("False", "NOBL2")
+            i_str = i_str.replace("CRYPTO", "Crypto")
+            i_str = i_str.replace("PROTECTED_STORAGE", "PS")
+            i_str = i_str.replace("INITIAL_ATTESTATION", "Attest")
+            i_str = i_str.replace("INTERNAL_TRUSTED_STORAGE", "ITS")
+            ret_cfg[i_str] = i
 
         return ret_cfg
 
diff --git a/tfm_ci_pylib/tfm_builder.py b/tfm_ci_pylib/tfm_builder.py
index 1908a8e..2125727 100644
--- a/tfm_ci_pylib/tfm_builder.py
+++ b/tfm_ci_pylib/tfm_builder.py
@@ -22,6 +22,7 @@
 
 import os
 import re
+import time
 import shutil
 from .utils import *
 from .structured_task import structuredTask
@@ -105,11 +106,165 @@
             if not os.path.exists(p):
                 os.makedirs(p)
 
+    def pre_build(self):
+        print("builder start %s \r\nself._tfb_cfg %s\r\n" %
+                (self, self._tfb_cfg))
+
+        try:
+            self._lock.acquire()
+            if self._tfb_code_base_updated:
+                print("Code base has been updated")
+                return True
+
+            self._tfb_code_base_updated = True
+            self._lock.release()
+
+            if "build_psa_api" in self._tfb_cfg:
+                # FF IPC build needs repo manifest update for TFM and PSA arch test
+                if "build_ff_ipc" in self._tfb_cfg:
+                    print("Checkout to FF IPC code base")
+                    os.chdir(self._tfb_cfg["codebase_root_dir"] + "/../psa-arch-tests/api-tests")
+                    _api_test_manifest = "git checkout . ; python3 tools/scripts/manifest_update.py"
+                    if subprocess_log(_api_test_manifest,
+                                      self._tfb_log_f,
+                                      append=True,
+                                      prefix=_api_test_manifest,
+                                      silent=self._tfb_silent):
+
+                        raise Exception("Python Failed please check log: %s" %
+                                        self._tfb_log_f)
+
+                    _api_test_manifest_tfm = "python3 tools/tfm_parse_manifest_list.py -m tools/tfm_psa_ff_test_manifest_list.yaml append"
+                    os.chdir(self._tfb_cfg["codebase_root_dir"])
+                    if subprocess_log(_api_test_manifest_tfm,
+                                      self._tfb_log_f,
+                                      append=True,
+                                      prefix=_api_test_manifest_tfm,
+                                      silent=self._tfb_silent):
+
+                        raise Exception("Python TFM Failed please check log: %s" %
+                                        self._tfb_log_f)
+                else:
+                    print("Checkout to default code base")
+                    os.chdir(self._tfb_cfg["codebase_root_dir"] + "/../psa-arch-tests/api-tests")
+                    _api_test_manifest = "git checkout ."
+                    if subprocess_log(_api_test_manifest,
+                                      self._tfb_log_f,
+                                      append=True,
+                                      prefix=_api_test_manifest,
+                                      silent=self._tfb_silent):
+
+                        raise Exception("Python Failed please check log: %s" %
+                                        self._tfb_log_f)
+
+                    _api_test_manifest_tfm = "python3 tools/tfm_parse_manifest_list.py"
+                    os.chdir(self._tfb_cfg["codebase_root_dir"])
+                    if subprocess_log(_api_test_manifest_tfm,
+                                      self._tfb_log_f,
+                                      append=True,
+                                      prefix=_api_test_manifest_tfm,
+                                      silent=self._tfb_silent):
+
+                        raise Exception("Python TFM Failed please check log: %s" %
+                                        self._tfb_log_f)
+        finally:
+            print("python pass after builder prepare")
+
+            p = self._tfb_build_dir + "/BUILD"
+            if not os.path.exists(p):
+                os.makedirs(p)
+
+            os.chdir(p)
+            if subprocess_log(self._tfb_cfg["build_psa_api"],
+                              self._tfb_log_f,
+                              append=True,
+                              prefix=self._tfb_cfg["build_psa_api"],
+                              silent=self._tfb_silent):
+
+                raise Exception("Build Failed please check log: %s" %
+                                self._tfb_log_f)
+    def copy_tfm(self):
+        """ Copy a new TFM for crypto compile """
+
+        cp_cmd = "cp -r " + self._tfb_cfg["codebase_root_dir"] + " " + \
+            self._tfb_build_dir
+        if subprocess_log(cp_cmd,
+                          self._tfb_log_f,
+                          append=True,
+                          prefix=cp_cmd,
+                          silent=self._tfb_silent):
+
+            raise Exception("Build Failed please check log: %s" %
+                            self._tfb_log_f)
+
+        cp_cmd = "cp -r " + self._tfb_cfg["codebase_root_dir"] + "/../mbed-crypto " + \
+            self._tfb_build_dir
+        if subprocess_log(cp_cmd,
+                          self._tfb_log_f,
+                          append=True,
+                          prefix=cp_cmd,
+                          silent=self._tfb_silent):
+
+            raise Exception("Build Failed please check log: %s" %
+                            self._tfb_log_f)
+
+        cp_cmd = "cp -r " + self._tfb_cfg["codebase_root_dir"] + "/../psa-arch-tests " + \
+            self._tfb_build_dir
+        if subprocess_log(cp_cmd,
+                          self._tfb_log_f,
+                          append=True,
+                          prefix=cp_cmd,
+                          silent=self._tfb_silent):
+
+            raise Exception("Build Failed please check log: %s" %
+                            self._tfb_log_f)
+
+
+        cp_cmd = "mkdir -p " + self._tfb_build_dir + "/CMSIS_5/CMSIS ; "
+        cp_cmd += "cp -r " + self._tfb_cfg["codebase_root_dir"] + "/../CMSIS_5/CMSIS/RTOS2 " + \
+                self._tfb_build_dir + "/CMSIS_5/CMSIS"
+
+        if subprocess_log(cp_cmd,
+                          self._tfb_log_f,
+                          append=True,
+                          prefix=cp_cmd,
+                          silent=self._tfb_silent):
+
+            raise Exception("Build Failed please check log: %s" %
+                            self._tfb_log_f)
+
+        self._tfb_cfg["build_cmds"][0] = \
+            self._tfb_cfg["build_cmds"][0].replace(self._tfb_cfg["codebase_root_dir"],
+            self._tfb_build_dir + "/tf-m")
+
     def task_exec(self):
         """ Main tasks """
 
         # Mark proccess running as status
         self.set_status(-1)
+        print("builder _tfb_cfg %s" % self._tfb_cfg)
+
+        if "build_psa_api" in self._tfb_cfg:
+            p = self._tfb_build_dir + "/BUILD"
+            if not os.path.exists(p):
+                os.makedirs(p)
+            os.chdir(p)
+            if subprocess_log(self._tfb_cfg["build_psa_api"],
+                              self._tfb_log_f,
+                              append=True,
+                              prefix=self._tfb_cfg["build_psa_api"],
+                              silent=self._tfb_silent):
+                raise Exception("Build Failed please check log: %s" %
+                                self._tfb_log_f)
+
+        if self._tfb_cfg["build_cmds"].__str__().find( \
+                "CRYPTO_HW_ACCELERATOR_OTP_STATE=ENABLED") > 0:
+            self.copy_tfm()
+            time.sleep(15)
+            os.sync()
+            print("new build cmd ", self._tfb_cfg["build_cmds"][0])
+
+        print("Go to build directory")
         # Go to build directory
         os.chdir(self._tfb_build_dir)
 
@@ -141,6 +296,7 @@
                                               "-j %s " % thread_no)
 
             # Build it
+            print("~builder build_cmd %s\r\n" % build_cmd)
             if subprocess_log(build_cmd,
                               self._tfb_log_f,
                               append=True,
diff --git a/tfm_ci_pylib/utils.py b/tfm_ci_pylib/utils.py
index 5df108a..c2312e5 100755
--- a/tfm_ci_pylib/utils.py
+++ b/tfm_ci_pylib/utils.py
@@ -357,7 +357,7 @@
 
     eabi_size = check_output(["arm-none-eabi-size",
                               filename],
-                             timeout=2).decode('UTF-8').rstrip()
+                             timeout=18).decode('UTF-8').rstrip()
 
     size_data = re.search(size_info_rex, eabi_size)