diff options
author | Marek Vasut <marex@denx.de> | 2023-02-09 13:30:10 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-02-23 13:32:20 -0500 |
commit | 5b4acb0ff79df642ef6b1e35fd4b193a4dc3c62b (patch) | |
tree | 418dbaf5a7f88305974186a1297ff2e9ae4c5aaa /env | |
parent | c1d266a781600f8c4c18449016edffb5597153cb (diff) | |
download | u-boot-5b4acb0ff79df642ef6b1e35fd4b193a4dc3c62b.zip u-boot-5b4acb0ff79df642ef6b1e35fd4b193a4dc3c62b.tar.gz u-boot-5b4acb0ff79df642ef6b1e35fd4b193a4dc3c62b.tar.bz2 |
env: mmc: Apply GPT only on eMMC user HW partitionWIP/2023-02-23-assorted-fixes
Apply the GPT U-Boot environment GUID type look up only on eMMC user
HW partition, do not apply the look up on eMMC boot HW partitions as
mmc_offset_try_partition() assumes either SD partitions or eMMC user
HW partition.
This fixes environment operation on systems where CONFIG_SYS_MMC_ENV_PART
is non-zero and CONFIG_SYS_REDUNDAND_ENVIRONMENT is set.
Fixes: 80105d8fd52 ("env: mmc: select GPT env partition by type guid")
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'env')
-rw-r--r-- | env/mmc.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -94,7 +94,7 @@ static inline int mmc_offset_try_partition(const char *str, int copy, s64 *val) return 0; } -static inline s64 mmc_offset(int copy) +static inline s64 mmc_offset(struct mmc *mmc, int copy) { const struct { const char *offset_redund; @@ -108,8 +108,12 @@ static inline s64 mmc_offset(int copy) s64 val = 0, defvalue; const char *propname; const char *str; + int hwpart = 0; int err; + if (IS_ENABLED(CONFIG_SYS_MMC_ENV_PART)) + hwpart = mmc_get_env_part(mmc); + /* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */ str = ofnode_conf_read_str(dt_prop.partition); if (str) { @@ -121,7 +125,7 @@ static inline s64 mmc_offset(int copy) } /* try the GPT partition with "U-Boot ENV" TYPE GUID */ - if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) { + if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) && hwpart == 0) { err = mmc_offset_try_partition(NULL, copy, &val); if (!err) return val; @@ -138,7 +142,7 @@ static inline s64 mmc_offset(int copy) return ofnode_conf_read_int(propname, defvalue); } #else -static inline s64 mmc_offset(int copy) +static inline s64 mmc_offset(struct mmc *mmc, int copy) { s64 offset = ENV_MMC_OFFSET; @@ -151,7 +155,7 @@ static inline s64 mmc_offset(int copy) __weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr) { - s64 offset = mmc_offset(copy); + s64 offset = mmc_offset(mmc, copy); if (offset == ENV_MMC_INVALID_OFFSET) { printf("Invalid ENV offset in MMC, copy=%d\n", copy); |