arm: Shorten the Firmware Update (FWU) process
authorAmbroise Vincent <ambroise.vincent@arm.com>
Thu, 4 Jul 2019 13:58:45 +0000 (14:58 +0100)
committerAmbroise Vincent <ambroise.vincent@arm.com>
Tue, 23 Jul 2019 09:41:41 +0000 (10:41 +0100)
The watchdog is configured with a default value of 256 seconds in order
to implement the Trusted Board Boot Requirements.

For the FVP and Juno platforms, the FWU process relies on a watchdog
reset. In order to automate the test of FWU, the length of this process
needs to be as short as possible. Instead of waiting for those 4 minutes
to have a reset by the watchdog, tell it to reset immediately.

There are no side effects as the value of the watchdog's load register
resets to 0xFFFFFFFF.

Tested on Juno.

Change-Id: Ib1aea80ceddc18ff1e0813a5b98dd141ba8a3ff2
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
20 files changed:
include/plat/arm/common/plat_arm.h
plat/arm/board/a5ds/a5ds_err.c [new file with mode: 0644]
plat/arm/board/a5ds/platform.mk
plat/arm/board/fvp/fvp_bl1_setup.c
plat/arm/board/fvp/fvp_err.c [new file with mode: 0644]
plat/arm/board/fvp/platform.mk
plat/arm/board/fvp_ve/fvp_ve_err.c [new file with mode: 0644]
plat/arm/board/fvp_ve/platform.mk
plat/arm/board/juno/juno_bl1_setup.c
plat/arm/board/juno/juno_err.c
plat/arm/board/juno/platform.mk
plat/arm/board/rde1edge/platform.mk
plat/arm/board/rde1edge/rde1edge_err.c [new file with mode: 0644]
plat/arm/board/rdn1edge/platform.mk
plat/arm/board/rdn1edge/rdn1edge_err.c [new file with mode: 0644]
plat/arm/board/sgi575/platform.mk
plat/arm/board/sgi575/sgi575_err.c [new file with mode: 0644]
plat/arm/board/sgm775/platform.mk
plat/arm/board/sgm775/sgm775_err.c [new file with mode: 0644]
plat/arm/common/arm_err.c

index 97e67225285123b31248bb983179fc4c23cf8ead..c8260e88abdaff8c66ee7bd5f2d13dcfbd5ac6c6 100644 (file)
@@ -252,7 +252,7 @@ void plat_arm_interconnect_enter_coherency(void);
 void plat_arm_interconnect_exit_coherency(void);
 void plat_arm_program_trusted_mailbox(uintptr_t address);
 int plat_arm_bl1_fwu_needed(void);
-void plat_arm_error_handler(int err);
+__dead2 void plat_arm_error_handler(int err);
 
 #if ARM_PLAT_MT
 unsigned int plat_arm_get_cpu_pe_count(u_register_t mpidr);
diff --git a/plat/arm/board/a5ds/a5ds_err.c b/plat/arm/board/a5ds/a5ds_err.c
new file mode 100644 (file)
index 0000000..65b41dd
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <plat/arm/common/plat_arm.h>
+
+/*
+ * a5ds error handler
+ */
+void __dead2 plat_arm_error_handler(int err)
+{
+       while (1) {
+               wfi();
+       }
+}
index 4fd357b8d599718dbe5ae8a8ff1662524f572a02..d42b2bfa89fdfca9d138194d6ea6440adae3b778 100644 (file)
@@ -36,6 +36,7 @@ BL1_SOURCES           +=      drivers/io/io_fip.c                             \
                                drivers/cfi/v2m/v2m_flash.c                     \
                                plat/arm/common/arm_bl1_setup.c                 \
                                plat/arm/common/arm_err.c                       \
+                               plat/arm/board/a5ds/a5ds_err.c                  \
                                plat/arm/common/arm_io_storage.c                \
                                plat/arm/board/a5ds/${ARCH}/a5ds_helpers.S      \
                                plat/arm/board/a5ds/a5ds_bl1_setup.c            \
@@ -55,6 +56,7 @@ BL2_SOURCES           +=      lib/aarch32/arm32_aeabi_divmod.c                \
                                plat/arm/board/a5ds/a5ds_bl2_setup.c            \
                                plat/arm/common/arm_bl2_setup.c                 \
                                plat/arm/common/arm_err.c                       \
+                               plat/arm/board/a5ds/a5ds_err.c                  \
                                plat/arm/common/arm_io_storage.c                \
                                plat/arm/common/${ARCH}/arm_bl2_mem_params_desc.c       \
                                plat/arm/common/arm_image_load.c                \
index 420df45595b0af6c4cab1f07cc6f303ecba60fe9..b90ddcd330fd6a9cc77fd3307332f265f7ab7615 100644 (file)
@@ -52,3 +52,12 @@ void bl1_platform_setup(void)
        if ((arm_config.flags & ARM_CONFIG_FVP_HAS_SMMUV3) != 0U)
                smmuv3_security_init(PLAT_FVP_SMMUV3_BASE);
 }
+
+__dead2 void bl1_plat_fwu_done(void *client_cookie, void *reserved)
+{
+       /* Setup the watchdog to reset the system as soon as possible */
+       sp805_refresh(ARM_SP805_TWDG_BASE, 1U);
+
+       while (1)
+               wfi();
+}
diff --git a/plat/arm/board/fvp/fvp_err.c b/plat/arm/board/fvp/fvp_err.c
new file mode 100644 (file)
index 0000000..2437cd4
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <errno.h>
+
+#include <common/debug.h>
+#include <drivers/arm/sp805.h>
+#include <drivers/cfi/v2m_flash.h>
+#include <plat/arm/common/plat_arm.h>
+#include <plat/common/platform.h>
+#include <platform_def.h>
+
+/*
+ * FVP error handler
+ */
+__dead2 void plat_arm_error_handler(int err)
+{
+       int ret;
+
+       switch (err) {
+       case -ENOENT:
+       case -EAUTH:
+               /* Image load or authentication error. Erase the ToC */
+               INFO("Erasing FIP ToC from flash...\n");
+               (void)nor_unlock(PLAT_ARM_FIP_BASE);
+               ret = nor_word_program(PLAT_ARM_FIP_BASE, 0);
+               if (ret != 0) {
+                       ERROR("Cannot erase ToC\n");
+               } else {
+                       INFO("Done\n");
+               }
+               break;
+       default:
+               /* Unexpected error */
+               break;
+       }
+
+       (void)console_flush();
+
+       /* Setup the watchdog to reset the system as soon as possible */
+       sp805_refresh(ARM_SP805_TWDG_BASE, 1U);
+
+       for (;;)
+               wfi();
+}
index bd6812b797699d1c74d6597ccd9970a2e012ff11..7981b69e61ade44e0a85677435111f45bffd5d52 100644 (file)
@@ -131,17 +131,20 @@ BL1_SOURCES               +=      drivers/arm/smmu/smmu_v3.c                      \
                                lib/semihosting/${ARCH}/semihosting_call.S      \
                                plat/arm/board/fvp/${ARCH}/fvp_helpers.S        \
                                plat/arm/board/fvp/fvp_bl1_setup.c              \
+                               plat/arm/board/fvp/fvp_err.c                    \
                                plat/arm/board/fvp/fvp_io_storage.c             \
                                plat/arm/board/fvp/fvp_trusted_boot.c           \
                                ${FVP_CPU_LIBS}                                 \
                                ${FVP_INTERCONNECT_SOURCES}
 
 
-BL2_SOURCES            +=      drivers/io/io_semihosting.c                     \
+BL2_SOURCES            +=      drivers/arm/sp805/sp805.c                       \
+                               drivers/io/io_semihosting.c                     \
                                lib/utils/mem_region.c                          \
                                lib/semihosting/semihosting.c                   \
                                lib/semihosting/${ARCH}/semihosting_call.S      \
                                plat/arm/board/fvp/fvp_bl2_setup.c              \
+                               plat/arm/board/fvp/fvp_err.c                    \
                                plat/arm/board/fvp/fvp_io_storage.c             \
                                plat/arm/board/fvp/fvp_trusted_boot.c           \
                                plat/arm/common/arm_nor_psci_mem_protect.c      \
diff --git a/plat/arm/board/fvp_ve/fvp_ve_err.c b/plat/arm/board/fvp_ve/fvp_ve_err.c
new file mode 100644 (file)
index 0000000..7f9d2f7
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <plat/arm/common/plat_arm.h>
+
+/*
+ * FVP VE error handler
+ */
+void __dead2 plat_arm_error_handler(int err)
+{
+       while (1) {
+               wfi();
+       }
+}
index f85452dac915a0290c980dae5b9498bb52d7278d..4d21f4ba0912ca42709846e504b3a35d3ce7581b 100644 (file)
@@ -40,6 +40,7 @@ BL1_SOURCES           +=      drivers/arm/sp805/sp805.c                       \
                                drivers/io/io_storage.c                         \
                                plat/arm/common/arm_bl1_setup.c                 \
                                plat/arm/common/arm_err.c                       \
+                               plat/arm/board/fvp_ve/fvp_ve_err.c              \
                                plat/arm/common/arm_io_storage.c                \
                                drivers/cfi/v2m/v2m_flash.c                     \
                                plat/arm/board/fvp_ve/${ARCH}/fvp_ve_helpers.S  \
@@ -60,6 +61,7 @@ BL2_SOURCES           +=      plat/arm/board/fvp_ve/fvp_ve_bl2_setup.c                \
                                drivers/io/io_storage.c                         \
                                plat/arm/common/arm_bl2_setup.c                 \
                                plat/arm/common/arm_err.c                       \
+                               plat/arm/board/fvp_ve/fvp_ve_err.c              \
                                plat/arm/common/arm_io_storage.c                \
                                plat/arm/common/${ARCH}/arm_bl2_mem_params_desc.c       \
                                plat/arm/common/arm_image_load.c                \
index 7a3d22dedc827b67bf0bbd484bf27c8b4f6b2ce4..89398d686d02e99722000b900ed88f785b71f844 100644 (file)
@@ -98,6 +98,9 @@ __dead2 void bl1_plat_fwu_done(void *client_cookie, void *reserved)
        /* Clear the NV flags register. */
        *nv_flags_clr = *nv_flags_ptr;
 
+       /* Setup the watchdog to reset the system as soon as possible */
+       sp805_refresh(ARM_SP805_TWDG_BASE, 1U);
+
        while (1)
                wfi();
 }
index 700b96cb1aa9fe3bc533061554f231df9a053b77..961bfda17a830f55ed902495b0573b1f98bdc1d1 100644 (file)
@@ -7,6 +7,7 @@
 #include <errno.h>
 
 #include <arch_helpers.h>
+#include <drivers/arm/sp805.h>
 #include <plat/arm/common/plat_arm.h>
 #include <plat/common/platform.h>
 #include <platform_def.h>
@@ -21,7 +22,9 @@ void __dead2 plat_arm_error_handler(int err)
        /* Propagate the err code in the NV-flags register */
        *flags_ptr = err;
 
-       /* Loop until the watchdog resets the system */
+       /* Setup the watchdog to reset the system as soon as possible */
+       sp805_refresh(ARM_SP805_TWDG_BASE, 1U);
+
        for (;;)
                wfi();
 }
index 40e62644b078548ffb83ffe621fdcac50f6ab22c..ea7f8517219f70ee010d0798f8ad50ec7df7449a 100644 (file)
@@ -66,7 +66,8 @@ BL1_SOURCES           +=      lib/cpus/aarch64/cortex_a53.S           \
                                ${JUNO_INTERCONNECT_SOURCES}            \
                                ${JUNO_SECURITY_SOURCES}
 
-BL2_SOURCES            +=      lib/utils/mem_region.c                  \
+BL2_SOURCES            +=      drivers/arm/sp805/sp805.c               \
+                               lib/utils/mem_region.c                  \
                                plat/arm/board/juno/juno_err.c          \
                                plat/arm/board/juno/juno_bl2_setup.c    \
                                plat/arm/common/arm_nor_psci_mem_protect.c \
index 833bb821af414692edfa3d0c771e80bbe8abbbda..db41e0eda6802ed40a49dcf097c9427048a2d4da 100644 (file)
@@ -12,10 +12,12 @@ PLAT_INCLUDES               +=      -I${RDE1EDGE_BASE}/include/
 
 SGI_CPU_SOURCES                :=      lib/cpus/aarch64/neoverse_e1.S
 
-BL1_SOURCES            +=      ${SGI_CPU_SOURCES}
+BL1_SOURCES            +=      ${SGI_CPU_SOURCES}                      \
+                               ${RDE1EDGE_BASE}/rde1edge_err.c
 
 BL2_SOURCES            +=      ${RDE1EDGE_BASE}/rde1edge_plat.c        \
                                ${RDE1EDGE_BASE}/rde1edge_security.c    \
+                               ${RDE1EDGE_BASE}/rde1edge_err.c         \
                                drivers/arm/tzc/tzc_dmc620.c            \
                                lib/utils/mem_region.c                  \
                                plat/arm/common/arm_nor_psci_mem_protect.c
diff --git a/plat/arm/board/rde1edge/rde1edge_err.c b/plat/arm/board/rde1edge/rde1edge_err.c
new file mode 100644 (file)
index 0000000..e344d82
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <plat/arm/common/plat_arm.h>
+
+/*
+ * rde1edge error handler
+ */
+void __dead2 plat_arm_error_handler(int err)
+{
+       while (1) {
+               wfi();
+       }
+}
index cacdaa13c26a04509a80f6aef9d50dd056fa95e2..b44c70a3b4339480871067cbf9277be6ef16b436 100644 (file)
@@ -12,10 +12,12 @@ PLAT_INCLUDES               +=      -I${RDN1EDGE_BASE}/include/
 
 SGI_CPU_SOURCES                :=      lib/cpus/aarch64/neoverse_n1.S
 
-BL1_SOURCES            +=      ${SGI_CPU_SOURCES}
+BL1_SOURCES            +=      ${SGI_CPU_SOURCES}                      \
+                               ${RDN1EDGE_BASE}/rdn1edge_err.c
 
 BL2_SOURCES            +=      ${RDN1EDGE_BASE}/rdn1edge_plat.c        \
                                ${RDN1EDGE_BASE}/rdn1edge_security.c    \
+                               ${RDN1EDGE_BASE}/rdn1edge_err.c         \
                                drivers/arm/tzc/tzc_dmc620.c            \
                                lib/utils/mem_region.c                  \
                                plat/arm/common/arm_nor_psci_mem_protect.c
diff --git a/plat/arm/board/rdn1edge/rdn1edge_err.c b/plat/arm/board/rdn1edge/rdn1edge_err.c
new file mode 100644 (file)
index 0000000..cdcbf25
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <plat/arm/common/plat_arm.h>
+
+/*
+ * rdn1edge error handler
+ */
+void __dead2 plat_arm_error_handler(int err)
+{
+       while (1) {
+               wfi();
+       }
+}
index e72225d370d3739c46260ba0a6c62e2df6a149c6..b9fa0995d26c920c57882005468764b04bb2fec4 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -12,10 +12,12 @@ PLAT_INCLUDES               +=      -I${SGI575_BASE}/include/
 
 SGI_CPU_SOURCES                :=      lib/cpus/aarch64/cortex_a75.S
 
-BL1_SOURCES            +=      ${SGI_CPU_SOURCES}
+BL1_SOURCES            +=      ${SGI_CPU_SOURCES}                      \
+                               ${SGI575_BASE}/sgi575_err.c
 
 BL2_SOURCES            +=      ${SGI575_BASE}/sgi575_plat.c            \
                                ${SGI575_BASE}/sgi575_security.c        \
+                               ${SGI575_BASE}/sgi575_err.c             \
                                drivers/arm/tzc/tzc_dmc620.c            \
                                lib/utils/mem_region.c                  \
                                plat/arm/common/arm_nor_psci_mem_protect.c
diff --git a/plat/arm/board/sgi575/sgi575_err.c b/plat/arm/board/sgi575/sgi575_err.c
new file mode 100644 (file)
index 0000000..c1cc1a7
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <plat/arm/common/plat_arm.h>
+
+/*
+ * sgi575 error handler
+ */
+void __dead2 plat_arm_error_handler(int err)
+{
+       while (1) {
+               wfi();
+       }
+}
index c8337554ac3a2bc1f6657b07b873e802a300a9ea..7a843c369caf6483277ec75b0a942ee49a9f58ec 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -12,7 +12,10 @@ FDT_SOURCES += ${SGM775_BASE}/fdts/sgm775_tb_fw_config.dts
 
 PLAT_INCLUDES +=-I${SGM775_BASE}/include/
 
+BL1_SOURCES            +=      ${SGM775_BASE}/sgm775_err.c
+
 BL2_SOURCES            +=      lib/utils/mem_region.c                  \
+                               ${SGM775_BASE}/sgm775_err.c             \
                                plat/arm/common/arm_nor_psci_mem_protect.c
 
 BL31_SOURCES           +=      drivers/cfi/v2m/v2m_flash.c             \
diff --git a/plat/arm/board/sgm775/sgm775_err.c b/plat/arm/board/sgm775/sgm775_err.c
new file mode 100644 (file)
index 0000000..e1e0586
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <plat/arm/common/plat_arm.h>
+
+/*
+ * sgm775 error handler
+ */
+void __dead2 plat_arm_error_handler(int err)
+{
+       while (1) {
+               wfi();
+       }
+}
index e77f5dc5c8c43a1dd4faa689068e6492c0d3bcee..f80ba78c7327254962b4fad964000a8a1d216978 100644 (file)
@@ -1,55 +1,14 @@
 /*
- * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
 #include <errno.h>
-#include <stdint.h>
 
-#include <platform_def.h>
-
-#include <arch_helpers.h>
-#include <common/debug.h>
-#include <drivers/cfi/v2m_flash.h>
-#include <drivers/console.h>
 #include <plat/arm/common/plat_arm.h>
 #include <plat/common/platform.h>
 
-#pragma weak plat_arm_error_handler
-
-/*
- * ARM common implementation for error handler
- */
-void __dead2 plat_arm_error_handler(int err)
-{
-       int ret;
-
-       switch (err) {
-       case -ENOENT:
-       case -EAUTH:
-               /* Image load or authentication error. Erase the ToC */
-               INFO("Erasing FIP ToC from flash...\n");
-               (void)nor_unlock(PLAT_ARM_FIP_BASE);
-               ret = nor_word_program(PLAT_ARM_FIP_BASE, 0);
-               if (ret != 0) {
-                       ERROR("Cannot erase ToC\n");
-               } else {
-                       INFO("Done\n");
-               }
-               break;
-       default:
-               /* Unexpected error */
-               break;
-       }
-
-       (void)console_flush();
-
-       /* Loop until the watchdog resets the system */
-       for (;;)
-               wfi();
-}
-
 void __dead2 plat_error_handler(int err)
 {
        plat_arm_error_handler(err);