Commit cbf77d20 authored by Alban Bedel's avatar Alban Bedel Committed by Priyanka Jain
Browse files

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: default avatarAlban Bedel <>
Reviewed-by: Priyanka Jain's avatarPriyanka Jain <>
parent 164941c2
......@@ -33,13 +33,10 @@
#include <fsl_validate.h>
#include <fsl_immap.h>
#include <env_internal.h>
#include <dm.h>
#include <dm/device_compat.h>
#include <linux/err.h>
#if defined(CONFIG_TFABOOT) || defined(CONFIG_GIC_V3_ITS)
......@@ -956,28 +953,12 @@ int board_late_init(void)
* check if gd->env_addr is default_environment; then setenv bootcmd
* and mcinitcmd.
if (gd->env_addr == (ulong)&default_environment[0]) {
if (gd->env_addr + gd->reloc_off == (ulong)&default_environment[0]) {
* 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.
if ((fsl_check_boot_mode_secure() == 1)) {
if (!env_get("bootcmd"))
if (!env_get("mcinitcmd"))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment