summaryrefslogtreecommitdiff
path: root/env
diff options
context:
space:
mode:
Diffstat (limited to 'env')
-rw-r--r--env/Kconfig126
-rw-r--r--env/Makefile1
-rw-r--r--env/common.c10
-rw-r--r--env/env.c3
-rw-r--r--env/fat.c8
-rw-r--r--env/mmc.c36
-rw-r--r--env/scsi.c115
-rw-r--r--env/sf.c6
-rw-r--r--env/ubi.c16
9 files changed, 233 insertions, 88 deletions
diff --git a/env/Kconfig b/env/Kconfig
index d7a7e81144b..c30785de48b 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -43,7 +43,7 @@ config ENV_OVERWRITE
Use this to permit overriding of certain environmental variables
like Ethernet and Serial
-config OVERWRITE_ETHADDR_ONCE
+config ENV_OVERWRITE_ETHADDR_ONCE
bool "Enable overwriting ethaddr environment variables once"
depends on !ENV_OVERWRITE
help
@@ -74,7 +74,7 @@ config ENV_IS_DEFAULT
!ENV_IS_IN_MMC && !ENV_IS_IN_NAND && \
!ENV_IS_IN_NVRAM && !ENV_IS_IN_ONENAND && \
!ENV_IS_IN_REMOTE && !ENV_IS_IN_SPI_FLASH && \
- !ENV_IS_IN_UBI && !ENV_IS_IN_MTD
+ !ENV_IS_IN_UBI && !ENV_IS_IN_MTD && !ENV_IS_IN_SCSI
select ENV_IS_NOWHERE
config ENV_IS_NOWHERE
@@ -215,11 +215,11 @@ config ENV_IS_IN_MMC
Define this if you have an MMC device which you want to use for the
environment.
- CONFIG_SYS_MMC_ENV_DEV:
+ CONFIG_ENV_MMC_DEVICE_INDEX:
Specifies which MMC device the environment is stored in.
- CONFIG_SYS_MMC_ENV_PART (optional):
+ CONFIG_ENV_MMC_EMMC_HW_PARTITION (optional):
Specifies which MMC partition the environment is stored in. If not
set, defaults to partition 0, the user area. Common values might be
@@ -231,14 +231,6 @@ config ENV_IS_IN_MMC
These two #defines specify the offset and size of the environment
area within the specified MMC device.
- If offset is positive (the usual case), it is treated as relative to
- the start of the MMC partition. If offset is negative, it is treated
- as relative to the end of the MMC partition. This can be useful if
- your board may be fitted with different MMC devices, which have
- different sizes for the MMC partitions, and you always want the
- environment placed at the very end of the partition, to leave the
- maximum possible space before it, to store other data.
-
These two values are in units of bytes, but must be aligned to an
MMC sector boundary.
@@ -249,10 +241,7 @@ config ENV_IS_IN_MMC
valid backup copy in case the other copy is corrupted, e.g. due
to a power failure during a "saveenv" operation.
- This value may also be positive or negative; this is handled in the
- same way as CONFIG_ENV_OFFSET.
-
- In case CONFIG_SYS_MMC_ENV_PART is 1 (i.e. environment in eMMC boot
+ In case CONFIG_ENV_MMC_EMMC_HW_PARTITION is 1 (i.e. environment in eMMC boot
partition) then setting CONFIG_ENV_OFFSET_REDUND to the same value
as CONFIG_ENV_OFFSET makes use of the second eMMC boot partition for
the redundant environment copy.
@@ -297,6 +286,13 @@ config ENV_IS_IN_NAND
Currently, CONFIG_ENV_OFFSET_REDUND is not supported when
using CONFIG_ENV_OFFSET_OOB.
+config ENV_IS_IN_SCSI
+ bool "Environment in an SCSI device"
+ depends on SCSI
+ help
+ Define this if you have an SCSI device which you want to use for the
+ environment.
+
config ENV_RANGE
hex "Length of the region in which the environment can be written"
depends on ENV_IS_IN_NAND
@@ -482,7 +478,7 @@ config ENV_IS_IN_UBI
the environment in. This will enable redundant environments in UBI.
It is assumed that both volumes are in the same MTD partition.
-config SYS_REDUNDAND_ENVIRONMENT
+config ENV_REDUNDANT
bool "Enable redundant environment support"
help
Normally, the environemt is stored in a single location. By
@@ -536,7 +532,7 @@ config ENV_FAT_FILE
config ENV_FAT_FILE_REDUND
string "Name of the FAT file to use for the environment"
- depends on ENV_IS_IN_FAT && SYS_REDUNDAND_ENVIRONMENT
+ depends on ENV_IS_IN_FAT && ENV_REDUNDANT
default "uboot-redund.env"
help
It's a string of the FAT file name. This file use to store the
@@ -588,7 +584,7 @@ config ENV_ADDR
config ENV_ADDR_REDUND
hex "Redundant environment address"
- depends on ENV_IS_IN_FLASH && SYS_REDUNDAND_ENVIRONMENT
+ depends on ENV_IS_IN_FLASH && ENV_REDUNDANT
help
Offset from the start of the device (or partition) of the redundant
environment location.
@@ -611,14 +607,23 @@ config ENV_OFFSET
Offset from the start of the device (or partition).
This offset may be interpreted differently depending on the chosen
- ENV_IS_IN_* options. For example, for ENV_IS_IN_MMC=y, this offset may
- be negative to indicate an offset backwards from the end of the
- partition. See the relevant help messages for more details.
+ ENV_IS_IN_* options. See the relevant help messages for more details.
+
+config ENV_OFFSET_RELATIVE_END
+ bool "Offset is relative to the end of the partition"
+ depends on ENV_IS_IN_MMC
+ help
+ Treat the environment offset as relative to the end of the MMC
+ hardware partition. This can be useful if your board may be fitted
+ with different MMC devices, which have different sizes for the MMC
+ hardware partitions, and you always want the environment placed at the
+ very end of the partition, to leave the maximum possible space before
+ it, to store other data.
config ENV_OFFSET_REDUND
hex "Redundant environment offset"
depends on (ENV_IS_IN_EEPROM || ENV_IS_IN_MMC || ENV_IS_IN_NAND || \
- ENV_IS_IN_SPI_FLASH) && SYS_REDUNDAND_ENVIRONMENT
+ ENV_IS_IN_SPI_FLASH) && ENV_REDUNDANT
default 0x10C0000 if MICROBLAZE
default 0x0
help
@@ -626,9 +631,19 @@ config ENV_OFFSET_REDUND
environment location.
This offset may be interpreted differently depending on the chosen
- ENV_IS_IN_* options. For example, for ENV_IS_IN_MMC=y, this offset may
- be negative to indicate an offset backwards from the end of the
- partition. See the relevant help messages for more details.
+ ENV_IS_IN_* options. See the relevant help messages for more details.
+
+config ENV_OFFSET_REDUND_RELATIVE_END
+ bool "Offset is relative to the end of the partition"
+ depends on SYS_REDUNDAND_ENVIRONMENT
+ depends on ENV_IS_IN_MMC
+ help
+ Treat the redundant environment offset as relative to the end of the
+ MMC hardware partition. This can be useful if your board may be
+ fitted with different MMC devices, which have different sizes for the
+ MMC hardware partitions, and you always want the environment placed at
+ the very end of the partition, to leave the maximum possible space
+ before it, to store other data.
config ENV_SIZE
hex "Environment Size"
@@ -668,7 +683,7 @@ config ENV_UBI_VOLUME
config ENV_UBI_VOLUME_REDUND
string "UBI redundant volume name"
- depends on ENV_IS_IN_UBI && SYS_REDUNDAND_ENVIRONMENT
+ depends on ENV_IS_IN_UBI && ENV_REDUNDANT
help
Name of the redundant volume that you want to store the environment in.
@@ -679,7 +694,7 @@ config ENV_UBI_VID_OFFSET
help
UBI VID offset for environment. If 0, no custom VID offset is used.
-config SYS_RELOC_GD_ENV_ADDR
+config ENV_RELOC_GD_ENV_ADDR
bool "Relocate gd->env_addr"
help
Relocate the early env_addr pointer so we know it is not inside
@@ -691,16 +706,18 @@ config ENV_MTD_DEV
help
MTD device name on the platform where the environment is stored.
-config SYS_MMC_ENV_DEV
- int "mmc device number"
+config ENV_MMC_DEVICE_INDEX
+ int "SD/MMC device index"
depends on ENV_IS_IN_MMC || ENV_IS_IN_FAT || ENV_IS_IN_EXT4 || \
CMD_MVEBU_BUBT || FMAN_ENET || QE || PHY_CORTINA
default 0
help
- MMC device number on the platform where the environment is stored.
+ SD/MMC device index on the platform where the environment is stored.
+ The index is often derived from DT aliases mmcN node ordering, and
+ matches the 'mmc list' command output.
-config SYS_MMC_ENV_PART
- int "mmc partition number"
+config ENV_MMC_EMMC_HW_PARTITION
+ int "eMMC hardware partition number"
depends on ENV_IS_IN_MMC || ENV_IS_IN_FAT
default 0
help
@@ -710,17 +727,20 @@ config SYS_MMC_ENV_PART
partition 0 or the first boot partition, which is 1 or some other defined
partition.
-config USE_ENV_MMC_PARTITION
- bool "use the mmc environment partition name"
+config ENV_MMC_USE_SW_PARTITION
+ bool "Use SD/MMC environment software partition name"
depends on ENV_IS_IN_MMC
-config ENV_MMC_PARTITION
- string "mmc environment partition name"
- depends on USE_ENV_MMC_PARTITION
+config ENV_MMC_SW_PARTITION
+ bool "SD/MMC environment software partition name"
+ depends on ENV_MMC_USE_SW_PARTITION
help
- MMC partition name used to save environment variables.
- If this variable is unset, u-boot will try to get the env partition name
- from the device-tree's /config node.
+ SD/MMC software partition name used to save environment variables.
+ This is a software partition name, i.e. one in partition table, not
+ an eMMC HW partition (see ENV_MMC_EMMC_HW_PARTITION for eMMC HW
+ partition configuration). If this variable is unset, u-boot will
+ try to get the env partition name from the device-tree's /config
+ node.
config ENV_MMC_USE_DT
bool "Read partition name and offset in DT"
@@ -731,7 +751,13 @@ config ENV_MMC_USE_DT
The 2 defines CONFIG_ENV_OFFSET, CONFIG_ENV_OFFSET_REDUND
are not used as fallback.
-config USE_DEFAULT_ENV_FILE
+config SCSI_ENV_PART_UUID
+ string "SCSI partition UUID for saving environment"
+ depends on ENV_IS_IN_SCSI
+ help
+ UUID of the SCSI partition that you want to store the environment in.
+
+config ENV_USE_DEFAULT_ENV_TEXT_FILE
bool "Create default environment from file"
help
Normally, the default environment is automatically generated
@@ -740,9 +766,9 @@ config USE_DEFAULT_ENV_FILE
you can instead define the entire default environment in an
external file.
-config DEFAULT_ENV_FILE
+config ENV_DEFAULT_ENV_TEXT_FILE
string "Path to default environment file"
- depends on USE_DEFAULT_ENV_FILE
+ depends on ENV_USE_DEFAULT_ENV_TEXT_FILE
help
The path containing the default environment. The format is
the same as accepted by the mkenvimage tool: lines
@@ -756,18 +782,6 @@ config ENV_VARS_UBOOT_RUNTIME_CONFIG
run-time determined information about the hardware to the
environment. These will be named board_name, board_rev.
-config DELAY_ENVIRONMENT
- bool "Delay environment loading"
- depends on !OF_CONTROL
- help
- Enable this to inhibit loading the environment during board
- initialization. This can address the security risk of untrusted data
- being used during boot. Normally the environment is loaded when the
- board is initialised so that it is available to U-Boot. This inhibits
- that so that the environment is not available until explicitly loaded
- later by U-Boot code. With CONFIG_OF_CONTROL this is instead
- controlled by the value of /config/load-environment.
-
config ENV_IMPORT_FDT
bool "Amend environment by FDT properties"
depends on OF_CONTROL
diff --git a/env/Makefile b/env/Makefile
index 3b9c71d5681..d11b87702c1 100644
--- a/env/Makefile
+++ b/env/Makefile
@@ -28,5 +28,6 @@ obj-$(CONFIG_$(PHASE_)ENV_IS_IN_NAND) += nand.o
obj-$(CONFIG_$(PHASE_)ENV_IS_IN_SPI_FLASH) += sf.o
obj-$(CONFIG_$(PHASE_)ENV_IS_IN_MTD) += mtd.o
obj-$(CONFIG_$(PHASE_)ENV_IS_IN_FLASH) += flash.o
+obj-$(CONFIG_$(PHASE_)ENV_IS_IN_SCSI) += scsi.o
CFLAGS_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2>/dev/null)
diff --git a/env/common.c b/env/common.c
index 86122582bc1..05e78d63874 100644
--- a/env/common.c
+++ b/env/common.c
@@ -82,6 +82,10 @@ int env_do_env_set(int flag, int argc, char *const argv[], int env_flag)
}
}
debug("Final value for argc=%d\n", argc);
+ /* Exit early if we don't have an env to apply */
+ if (argc < 2)
+ return 0;
+
name = argv[1];
if (strchr(name, '=')) {
@@ -466,7 +470,7 @@ int env_import(const char *buf, int check, int flags)
return -EIO;
}
-#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#ifdef CONFIG_ENV_REDUNDANT
static unsigned char env_flags;
int env_check_redund(const char *buf1, int buf1_read_fail,
@@ -543,7 +547,7 @@ int env_import_redund(const char *buf1, int buf1_read_fail,
return env_import((char *)ep, 0, flags);
}
-#endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */
+#endif /* CONFIG_ENV_REDUNDANT */
/* Export the environment and generate CRC for it. */
int env_export(env_t *env_out)
@@ -560,7 +564,7 @@ int env_export(env_t *env_out)
env_out->crc = crc32(0, env_out->data, ENV_SIZE);
-#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#ifdef CONFIG_ENV_REDUNDANT
env_out->flags = ++env_flags; /* increase the serial */
#endif
diff --git a/env/env.c b/env/env.c
index dbaeedc3c3b..7a9c96b4078 100644
--- a/env/env.c
+++ b/env/env.c
@@ -46,6 +46,9 @@ static enum env_location env_locations[] = {
#ifdef CONFIG_ENV_IS_IN_MMC
ENVL_MMC,
#endif
+#ifdef CONFIG_ENV_IS_IN_SCSI
+ ENVL_SCSI,
+#endif
#ifdef CONFIG_ENV_IS_IN_NAND
ENVL_NAND,
#endif
diff --git a/env/fat.c b/env/fat.c
index 1ad301eaaff..65ee1c8e086 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -86,7 +86,7 @@ static int env_fat_save(void)
return 1;
}
-#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#ifdef CONFIG_ENV_REDUNDANT
if (gd->env_valid == ENV_VALID)
file = CONFIG_ENV_FAT_FILE_REDUND;
#endif
@@ -101,7 +101,7 @@ static int env_fat_save(void)
return 1;
}
-#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#ifdef CONFIG_ENV_REDUNDANT
gd->env_valid = (gd->env_valid == ENV_REDUND) ? ENV_VALID : ENV_REDUND;
#endif
@@ -112,7 +112,7 @@ static int env_fat_save(void)
static int env_fat_load(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, buf1, CONFIG_ENV_SIZE);
-#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#ifdef CONFIG_ENV_REDUNDANT
ALLOC_CACHE_ALIGN_BUFFER(char, buf2, CONFIG_ENV_SIZE);
int err2;
#endif
@@ -153,7 +153,7 @@ static int env_fat_load(void)
}
err1 = file_fat_read(CONFIG_ENV_FAT_FILE, buf1, CONFIG_ENV_SIZE);
-#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#ifdef CONFIG_ENV_REDUNDANT
err2 = file_fat_read(CONFIG_ENV_FAT_FILE_REDUND, buf2, CONFIG_ENV_SIZE);
err1 = (err1 >= 0) ? 0 : -1;
diff --git a/env/mmc.c b/env/mmc.c
index 8848371eb4f..46ffa6386d6 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -29,11 +29,19 @@
#else
/* Default ENV offset when not defined in Device Tree */
+#if !defined(CONFIG_ENV_OFFSET_RELATIVE_END)
#define ENV_MMC_OFFSET CONFIG_ENV_OFFSET
+#else
+#define ENV_MMC_OFFSET (-(CONFIG_ENV_OFFSET))
+#endif
#if defined(CONFIG_ENV_OFFSET_REDUND)
+#if !defined(CONFIG_ENV_OFFSET_REDUND_RELATIVE_END)
#define ENV_MMC_OFFSET_REDUND CONFIG_ENV_OFFSET_REDUND
#else
+#define ENV_MMC_OFFSET_REDUND (-(CONFIG_ENV_OFFSET_REDUND))
+#endif
+#else
#define ENV_MMC_OFFSET_REDUND ENV_MMC_INVALID_OFFSET
#endif
#endif
@@ -157,14 +165,14 @@ static inline s64 mmc_offset(struct mmc *mmc, int copy)
int hwpart = 0;
int err;
-#if defined(CONFIG_SYS_MMC_ENV_PART)
+#if defined(CONFIG_ENV_MMC_EMMC_HW_PARTITION)
hwpart = mmc_get_env_part(mmc);
#endif
-#if defined(CONFIG_ENV_MMC_PARTITION)
- str = CONFIG_ENV_MMC_PARTITION;
+#if defined(CONFIG_ENV_MMC_SW_PARTITION)
+ str = CONFIG_ENV_MMC_SW_PARTITION;
#else
- /* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */
+ /* look for the partition in mmc CONFIG_ENV_MMC_DEVICE_INDEX */
str = ofnode_conf_read_str(dt_prop.partition);
#endif
@@ -186,7 +194,7 @@ static inline s64 mmc_offset(struct mmc *mmc, int copy)
defvalue = ENV_MMC_OFFSET;
propname = dt_prop.offset;
- if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT) && copy) {
+ if (IS_ENABLED(CONFIG_ENV_REDUNDANT) && copy) {
defvalue = ENV_MMC_OFFSET_REDUND;
propname = dt_prop.offset_redund;
}
@@ -198,7 +206,7 @@ static inline s64 mmc_offset(struct mmc *mmc, int copy)
{
s64 offset = ENV_MMC_OFFSET;
- if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT) && copy)
+ if (IS_ENABLED(CONFIG_ENV_REDUNDANT) && copy)
offset = ENV_MMC_OFFSET_REDUND;
return offset;
@@ -213,10 +221,10 @@ static bool mmc_env_is_redundant_in_both_boot_hwparts(struct mmc *mmc)
* identical, store the environment and redundant environment in both
* eMMC boot partitions, one copy in each.
*/
- if (!IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT))
+ if (!IS_ENABLED(CONFIG_ENV_REDUNDANT))
return false;
- if (CONFIG_SYS_MMC_ENV_PART != 1)
+ if (CONFIG_ENV_MMC_EMMC_HW_PARTITION != 1)
return false;
return mmc_offset(mmc, 0) == mmc_offset(mmc, 1);
@@ -239,10 +247,10 @@ __weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
return 0;
}
-#ifdef CONFIG_SYS_MMC_ENV_PART
+#ifdef CONFIG_ENV_MMC_EMMC_HW_PARTITION
__weak uint mmc_get_env_part(struct mmc *mmc)
{
- return CONFIG_SYS_MMC_ENV_PART;
+ return CONFIG_ENV_MMC_EMMC_HW_PARTITION;
}
static unsigned char env_mmc_orig_hwpart;
@@ -337,7 +345,7 @@ static int env_mmc_save(void)
if (ret)
goto fini;
- if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT)) {
+ if (IS_ENABLED(CONFIG_ENV_REDUNDANT)) {
if (gd->env_valid == ENV_VALID)
copy = 1;
@@ -362,7 +370,7 @@ static int env_mmc_save(void)
ret = 0;
- if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT))
+ if (IS_ENABLED(CONFIG_ENV_REDUNDANT))
gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND;
fini:
@@ -411,7 +419,7 @@ static int env_mmc_erase(void)
printf("\n");
ret = erase_env(mmc, CONFIG_ENV_SIZE, offset);
- if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT)) {
+ if (IS_ENABLED(CONFIG_ENV_REDUNDANT)) {
copy = 1;
if (mmc_env_is_redundant_in_both_boot_hwparts(mmc)) {
@@ -555,7 +563,7 @@ static int env_mmc_load(void)
{
if (IS_ENABLED(ENV_IS_EMBEDDED))
return 0;
- else if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT))
+ else if (IS_ENABLED(CONFIG_ENV_REDUNDANT))
return env_mmc_load_redundant();
else
return env_mmc_load_singular();
diff --git a/env/scsi.c b/env/scsi.c
new file mode 100644
index 00000000000..207717e17b1
--- /dev/null
+++ b/env/scsi.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2008-2011 Freescale Semiconductor, Inc.
+ */
+
+/* #define DEBUG */
+
+#include <asm/global_data.h>
+
+#include <command.h>
+#include <env.h>
+#include <env_internal.h>
+#include <fdtdec.h>
+#include <linux/stddef.h>
+#include <malloc.h>
+#include <memalign.h>
+#include <part.h>
+#include <search.h>
+#include <scsi.h>
+#include <errno.h>
+#include <dm/ofnode.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+static env_t envbuf;
+
+struct env_scsi_info {
+ struct blk_desc *blk;
+ struct disk_partition part;
+ int count;
+};
+
+static struct env_scsi_info env_part;
+
+static inline struct env_scsi_info *env_scsi_get_part(void)
+{
+ struct env_scsi_info *ep = &env_part;
+
+ if (scsi_get_blk_by_uuid(CONFIG_SCSI_ENV_PART_UUID, &ep->blk, &ep->part))
+ return NULL;
+
+ ep->count = CONFIG_ENV_SIZE / ep->part.blksz;
+
+ return ep;
+}
+
+static int env_scsi_save(void)
+{
+ struct env_scsi_info *ep = env_scsi_get_part();
+ int ret;
+
+ if (!ep)
+ return -ENOENT;
+
+ ret = env_export(&envbuf);
+ if (ret)
+ return ret;
+
+ if (blk_dwrite(ep->blk, ep->part.start, ep->count, &envbuf) != ep->count)
+ return -EIO;
+
+ return 0;
+}
+
+static int env_scsi_erase(void)
+{
+ struct env_scsi_info *ep = env_scsi_get_part();
+
+ if (!ep)
+ return -ENOENT;
+
+ return (int)blk_derase(ep->blk, ep->part.start, ep->count);
+}
+
+#if defined(ENV_IS_EMBEDDED)
+static int env_scsi_load(void)
+{
+ return 0;
+}
+#else
+static int env_scsi_load(void)
+{
+ struct env_scsi_info *ep = env_scsi_get_part();
+ int ret;
+
+ if (!ep) {
+ env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition not found", 0);
+ return -ENOENT;
+ }
+
+ if (blk_dread(ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) {
+ env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition read failed", 0);
+ return -EIO;
+ }
+
+ ret = env_import((char *)&envbuf, 1, H_EXTERNAL);
+ if (ret) {
+ debug("ENV import failed\n");
+ env_set_default("Cannot load environment", 0);
+ } else {
+ gd->env_addr = (ulong)envbuf.data;
+ }
+
+ return ret;
+}
+#endif
+
+U_BOOT_ENV_LOCATION(scsi) = {
+ .location = ENVL_SCSI,
+ ENV_NAME("SCSI")
+ .load = env_scsi_load,
+#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_XPL_BUILD)
+ .save = env_save_ptr(env_scsi_save),
+ .erase = ENV_ERASE_PTR(env_scsi_erase),
+#endif
+};
diff --git a/env/sf.c b/env/sf.c
index eb4c8d5ec95..0b70e18b9af 100644
--- a/env/sf.c
+++ b/env/sf.c
@@ -380,7 +380,7 @@ static int env_sf_init_early(void)
tmp_env1 = (env_t *)memalign(ARCH_DMA_MINALIGN,
CONFIG_ENV_SIZE);
- if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT))
+ if (IS_ENABLED(CONFIG_ENV_REDUNDANT))
tmp_env2 = (env_t *)memalign(ARCH_DMA_MINALIGN,
CONFIG_ENV_SIZE);
@@ -394,7 +394,7 @@ static int env_sf_init_early(void)
read1_fail = spi_flash_read(env_flash, CONFIG_ENV_OFFSET,
CONFIG_ENV_SIZE, tmp_env1);
- if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT)) {
+ if (IS_ENABLED(CONFIG_ENV_REDUNDANT)) {
read2_fail = spi_flash_read(env_flash,
CONFIG_ENV_OFFSET_REDUND,
CONFIG_ENV_SIZE, tmp_env2);
@@ -429,7 +429,7 @@ err_read:
spi_flash_free(env_flash);
free(tmp_env1);
- if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT))
+ if (IS_ENABLED(CONFIG_ENV_REDUNDANT))
free(tmp_env2);
out:
/* env is not valid. always return 0 */
diff --git a/env/ubi.c b/env/ubi.c
index 2f4ca571edb..f424b1a16e8 100644
--- a/env/ubi.c
+++ b/env/ubi.c
@@ -27,14 +27,14 @@
DECLARE_GLOBAL_DATA_PTR;
-#if CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#if CONFIG_ENV_REDUNDANT
#define ENV_UBI_VOLUME_REDUND CONFIG_ENV_UBI_VOLUME_REDUND
#else
#define ENV_UBI_VOLUME_REDUND "invalid"
#endif
#ifdef CONFIG_CMD_SAVEENV
-#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#ifdef CONFIG_ENV_REDUNDANT
static int env_ubi_save(void)
{
ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
@@ -76,7 +76,7 @@ static int env_ubi_save(void)
return 0;
}
-#else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */
+#else /* ! CONFIG_ENV_REDUNDANT */
static int env_ubi_save(void)
{
ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
@@ -102,10 +102,10 @@ static int env_ubi_save(void)
puts("done\n");
return 0;
}
-#endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */
+#endif /* CONFIG_ENV_REDUNDANT */
#endif /* CONFIG_CMD_SAVEENV */
-#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#ifdef CONFIG_ENV_REDUNDANT
static int env_ubi_load(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, env1_buf, CONFIG_ENV_SIZE);
@@ -149,7 +149,7 @@ static int env_ubi_load(void)
return env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
read2_fail, H_EXTERNAL);
}
-#else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */
+#else /* ! CONFIG_ENV_REDUNDANT */
static int env_ubi_load(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -180,7 +180,7 @@ static int env_ubi_load(void)
return env_import(buf, 1, H_EXTERNAL);
}
-#endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */
+#endif /* CONFIG_ENV_REDUNDANT */
static int env_ubi_erase(void)
{
@@ -202,7 +202,7 @@ static int env_ubi_erase(void)
CONFIG_ENV_UBI_VOLUME);
ret = 1;
}
- if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT)) {
+ if (IS_ENABLED(CONFIG_ENV_REDUNDANT)) {
if (ubi_volume_write(ENV_UBI_VOLUME_REDUND,
(void *)env_buf, 0, CONFIG_ENV_SIZE)) {
printf("\n** Unable to erase env to %s:%s **\n",