From 5330bd8f569afffe978350ee15ba84599af3632d Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 20 Sep 2016 18:15:35 -0700 Subject: toradex: common: add common code which avoids loading environment Add common code for i.MX SoC's which avoids loading the environment. This reimplements the functionaltiy lost with ("common: autoboot: do not reset environment") by not loading the environment from the beginning. The main difference will be that dynamically set environment variables such as "soc" in the i.MX 7 case will still be set. Signed-off-by: Stefan Agner Acked-by: Marcel Ziswiler --- board/toradex/common/common-imx.c | 20 ++++++++++++++++++++ board/toradex/common/common.mk | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 board/toradex/common/common-imx.c diff --git a/board/toradex/common/common-imx.c b/board/toradex/common/common-imx.c new file mode 100644 index 0000000000..0fa3402eed --- /dev/null +++ b/board/toradex/common/common-imx.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2016 Toradex, Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include + +int should_load_env(void) +{ + /* Do not load environment from eMMC/NAND, it could be hostile */ + if (is_boot_from_usb()) { + puts("Serial Downloader mode, not loading environment\n"); + return 0; + } + + return 1; +} diff --git a/board/toradex/common/common.mk b/board/toradex/common/common.mk index 469189a315..2679dea169 100644 --- a/board/toradex/common/common.mk +++ b/board/toradex/common/common.mk @@ -5,4 +5,7 @@ obj- := __dummy__.o else obj-$(CONFIG_TRDX_CFG_BLOCK) += ../common/configblock.o obj-y += ../common/common.o +ifeq ($(SOC),$(filter $(SOC),mx6 mx7)) +obj-y += ../common/common-imx.o +endif endif -- cgit v1.2.3