From: Stephen Warren <swar...@nvidia.com>

A negative value of CONFIG_ENV_OFFSET is treated as a backwards offset
from the end of the eMMC device/partition, rather than a forwards offset
from the start.

This is useful when a single board may be stuffed with different eMMC
devices, each of which has a different capacity, and you always want the
environment to be stored at the very end of the device (or eMMC boot
partition for example).

One example of this case is NVIDIA's Ventana reference board.

Signed-off-by: Stephen Warren <swar...@nvidia.com>
---
 common/env_mmc.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/common/env_mmc.c b/common/env_mmc.c
index 02bd5ae..4448085 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -48,7 +48,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 __weak int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
 {
-       *env_addr = CONFIG_ENV_OFFSET;
+       if (CONFIG_ENV_OFFSET < 0)
+               *env_addr = mmc->capacity + CONFIG_ENV_OFFSET;
+       else
+               *env_addr = CONFIG_ENV_OFFSET;
+
        return 0;
 }
 
-- 
1.7.10.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to