Add srec_cat Command for MUSCA

Change-Id: I03fc28261e1ebb1c9956de5db9a4e8d623a6223d
Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
diff --git a/build_helper/build_helper_configs.py b/build_helper/build_helper_configs.py
index 465ffc0..1490a0d 100755
--- a/build_helper/build_helper_configs.py
+++ b/build_helper/build_helper_configs.py
@@ -75,33 +75,33 @@
     # ALL commands will be executed for every build.
     # Other keys will append extra commands when matching target_platform
     "build_cmds": {"all": ["cmake --build ./ -- install"],
-                   "MUSCA_A": [("srec_cat "
+                   "musca_a": [("srec_cat "
                                 "%(_tbm_build_dir_)s/bin/"
                                 "bl2.bin "
                                 "-Binary -offset 0x200000 "
                                 "%(_tbm_build_dir_)s/bin/"
-                                "%tfm_s_ns_signed.bin "
+                                "tfm_s_ns_signed.bin "
                                 "-Binary -offset 0x220000 -o "
                                 "%(_tbm_build_dir_)s/bin/"
-                                "/tfm.hex -Intel")],
-                   "MUSCA_B1": [("srec_cat "
+                                "tfm.hex -Intel")],
+                   "musca_b1": [("srec_cat "
                                  "%(_tbm_build_dir_)s/bin/"
                                  "bl2.bin "
                                  "-Binary -offset 0xA000000 "
                                  "%(_tbm_build_dir_)s/bin/"
-                                 "%tfm_s_ns_signed.bin "
+                                 "tfm_s_ns_signed.bin "
                                  "-Binary -offset 0xA020000 -o "
                                  "%(_tbm_build_dir_)s/bin/"
-                                 "/tfm.hex -Intel")],
-                   "MUSCA_S1": [("srec_cat "
+                                 "tfm.hex -Intel")],
+                   "musca_s1": [("srec_cat "
                                  "%(_tbm_build_dir_)s/bin/"
                                  "bl2.bin "
                                  "-Binary -offset 0xA000000 "
                                  "%(_tbm_build_dir_)s/bin/"
-                                 "%tfm_s_ns_signed.bin "
+                                 "tfm_s_ns_signed.bin "
                                  "-Binary -offset 0xA020000 -o "
                                  "%(_tbm_build_dir_)s/bin/"
-                                 "/tfm.hex -Intel")]
+                                 "tfm.hex -Intel")]
                    },
 
     # (Optional) If set will fail if those artefacts are missing post build
@@ -110,25 +110,25 @@
                            "tfm_s.bin",
                            "%(_tbm_build_dir_)s/bin/"
                            "tfm_ns.bin"],
-                           "MUSCA_A": [
+                           "musca_a": [
                            "%(_tbm_build_dir_)s/bin/"
                            "tfm.hex",
                            "%(_tbm_build_dir_)s/bin/"
-                           "mcuboot.bin",
+                           "bl2.bin",
                            "%(_tbm_build_dir_)s/bin/"
                            "tfm_sign.bin"],
-                           "MUSCA_B1": [
+                           "musca_b1": [
                            "%(_tbm_build_dir_)s/bin/"
                            "tfm.hex",
                            "%(_tbm_build_dir_)s/bin/"
-                           "mcuboot.bin",
+                           "bl2.bin",
                            "%(_tbm_build_dir_)s/bin/"
                            "tfm_sign.bin"],
-                           "MUSCA_S1": [
+                           "musca_s1": [
                            "%(_tbm_build_dir_)s/bin/"
                            "tfm.hex",
                            "%(_tbm_build_dir_)s/bin/"
-                           "mcuboot.bin",
+                           "bl2.bin",
                            "%(_tbm_build_dir_)s/bin/"
                            "tfm_sign.bin"]
                            }
diff --git a/jenkins/build-config.jpl b/jenkins/build-config.jpl
index 06e8a71..f57d0cd 100644
--- a/jenkins/build-config.jpl
+++ b/jenkins/build-config.jpl
@@ -99,6 +99,7 @@
     }
     stage("Post") {
       archiveArtifacts 'trusted-firmware-m/build/install/**'
+      archiveArtifacts 'trusted-firmware-m/build/bin/**'
     }
   } catch (Exception e) {
     manager.buildFailure()
diff --git a/tfm_ci_pylib/tfm_build_manager.py b/tfm_ci_pylib/tfm_build_manager.py
index 7d56c7a..a43612a 100644
--- a/tfm_ci_pylib/tfm_build_manager.py
+++ b/tfm_ci_pylib/tfm_build_manager.py
@@ -151,7 +151,9 @@
         codebase_dir = os.path.join(os.getcwd(),"trusted-firmware-m")
         build_dir=os.path.join(os.getcwd(),"trusted-firmware-m/build")
         build_config = self.get_build_config(config_details, config, silence=silence_stderr, build_dir=build_dir, codebase_dir=codebase_dir)
-        build_commands = [build_config["config_template"], build_config["build_cmds"][0]]
+        build_commands = [build_config["config_template"]]
+        for command in build_config["build_cmds"]:
+            build_commands.append(command)
         print(" ;\n".join(build_commands))
 
     def pre_eval(self):
@@ -372,7 +374,7 @@
         # Extract the platform specific elements of config
         for key in ["build_cmds", "required_artefacts"]:
             try:
-                if i.tfm_platform in self.tbm_common_cfg[key].keys():
+                if i.tfm_platform in self.tbm_common_cfg[key].keys() and i.with_ns:
                     build_cfg[key] += deepcopy(self.tbm_common_cfg[key]
                                                [i.tfm_platform])
             except Exception as E:
@@ -399,6 +401,9 @@
                             "profile": "" if i.profile=="N.A" else i.profile,
                             "partition_ps": i.partition_ps}
         build_cfg["config_template"] %= overwrite_params
+        if len(build_cfg["build_cmds"]) > 1:
+            overwrite_build_dir = {"_tbm_build_dir_": build_dir}
+            build_cfg["build_cmds"][1] %= overwrite_build_dir
         return build_cfg
 
     def post_eval(self):