All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] armv8: fsl-layerscape: Fix automatic setting of bootmcd with TF-A
@ 2020-11-17 15:20 Alban Bedel
  2020-12-11  7:56 ` Priyanka Jain
  0 siblings, 1 reply; 2+ messages in thread
From: Alban Bedel @ 2020-11-17 15:20 UTC (permalink / raw)
  To: u-boot

When booting from TF-A there is a logic that attempt to detect if the
default environment is used, if this is the case it then set the
`bootcmd` and `mcinitcmd` depending of the device we booted from.
This detection logic is dubious as it access internals of the env
implementation and it doesn't always work correctly.

First of all it detect any valid environment as not being the
default, so after running `env default -a && saveenv` the board
doesn't boot anymore as `bootcmd` is then empty.
But it also fails in some other ways, for example it always detect a
default environment when redundant env is enabled on MMC, so in that
case `bootcmd` is overwritten on every boot.

Instead of increasing the complexity of the detection just check if
`bootcmd` and `mcinitcmd` are set in the environment and set them if
they are not.

Signed-off-by: Alban Bedel <alban.bedel@aerq.com>
---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 27 ++++---------------------
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index 96b2775f3f..af9399278f 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -33,13 +33,10 @@
 #include <fsl_validate.h>
 #endif
 #include <fsl_immap.h>
-#ifdef CONFIG_TFABOOT
-#include <env_internal.h>
-#endif
 #include <dm.h>
 #include <dm/device_compat.h>
 #include <linux/err.h>
-#if defined(CONFIG_TFABOOT) || defined(CONFIG_GIC_V3_ITS)
+#ifdef CONFIG_GIC_V3_ITS
 DECLARE_GLOBAL_DATA_PTR;
 #endif
 
@@ -954,28 +951,12 @@ int board_late_init(void)
 #endif
 #ifdef CONFIG_TFABOOT
 	/*
-	 * check if gd->env_addr is default_environment; then setenv bootcmd
-	 * and mcinitcmd.
-	 */
-#ifdef CONFIG_SYS_RELOC_GD_ENV_ADDR
-	if (gd->env_addr == (ulong)&default_environment[0]) {
-#else
-	if (gd->env_addr + gd->reloc_off == (ulong)&default_environment[0]) {
-#endif
-		fsl_setenv_bootcmd();
-		fsl_setenv_mcinitcmd();
-	}
-
-	/*
-	 * If the boot mode is secure, default environment is not present then
-	 * setenv command needs to be run by default
+	 * Set bootcmd and mcinitcmd if they don't exist in the environment.
 	 */
-#ifdef CONFIG_CHAIN_OF_TRUST
-	if ((fsl_check_boot_mode_secure() == 1)) {
+	if (!env_get("bootcmd"))
 		fsl_setenv_bootcmd();
+	if (!env_get("mcinitcmd"))
 		fsl_setenv_mcinitcmd();
-	}
-#endif
 #endif
 #ifdef CONFIG_QSPI_AHB_INIT
 	qspi_ahb_init();
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] armv8: fsl-layerscape: Fix automatic setting of bootmcd with TF-A
  2020-11-17 15:20 [PATCH] armv8: fsl-layerscape: Fix automatic setting of bootmcd with TF-A Alban Bedel
@ 2020-12-11  7:56 ` Priyanka Jain
  0 siblings, 0 replies; 2+ messages in thread
From: Priyanka Jain @ 2020-12-11  7:56 UTC (permalink / raw)
  To: u-boot

>-----Original Message-----
>From: Alban Bedel <alban.bedel@aerq.com>
>Sent: Tuesday, November 17, 2020 8:50 PM
>To: u-boot at lists.denx.de
>Cc: Priyanka Jain <priyanka.jain@nxp.com>; Pankit Garg
><pankit.garg@nxp.com>; Bedel, Alban <alban.bedel@aerq.com>
>Subject: [PATCH] armv8: fsl-layerscape: Fix automatic setting of bootmcd with
>TF-A
>
>When booting from TF-A there is a logic that attempt to detect if the default
>environment is used, if this is the case it then set the `bootcmd` and
>`mcinitcmd` depending of the device we booted from.
>This detection logic is dubious as it access internals of the env implementation
>and it doesn't always work correctly.
>
>First of all it detect any valid environment as not being the default, so after
>running `env default -a && saveenv` the board doesn't boot anymore as
>`bootcmd` is then empty.
>But it also fails in some other ways, for example it always detect a default
>environment when redundant env is enabled on MMC, so in that case
>`bootcmd` is overwritten on every boot.
>
>Instead of increasing the complexity of the detection just check if `bootcmd`
>and `mcinitcmd` are set in the environment and set them if they are not.
>
>Signed-off-by: Alban Bedel <alban.bedel@aerq.com>
>---
<snip>
Applied to fsl-qoriq. 
Awaiting upstream

Regards
Priyanka

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-11  7:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 15:20 [PATCH] armv8: fsl-layerscape: Fix automatic setting of bootmcd with TF-A Alban Bedel
2020-12-11  7:56 ` Priyanka Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.