env: mmc: allow support of mmc_get_env_dev with OF_CONTROL
cover env: mmc: allow support of mmc_get_env_dev with OF_CONTROL
Hi Joe,
It is a resend of previous serie [1] after rebase.
This serie provides several corrections on ENV suport in MMC partition. No code modification on this RESEND, tested on STM32MP157C-EV1.
[1] http://patchwork.ozlabs.org/project/uboot/list/?series=165325
Regards
Patrick
Patrick Delaunay (3):
env: mmc: allow support of mmc_get_env_dev with OF_CONTROL
env: mmc: correct the offset returned by mmc_offset_try_partition
env: mmc: add redundancy support in mmc_offset_try_partition
env/mmc.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
Signature · 1 line
2.17.1
PATCH RESEND 1/3 env: mmc: allow support of mmc_get_env_dev with OF_CONTROL
Use the weak function mmc_get_env_dev in mmc_offset_try_partition function to allow dynamic selection of mmc device to use and no more use directly the define CONFIG_SYS_MMC_ENV_DEV.
---
env/mmc.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
env/mmc.c +12 -6
@@ -24,14 +24,25 @@DECLARE_GLOBAL_DATA_PTR ; +#if !defined(CONFIG_SYS_MMC_ENV_DEV ) +#define CONFIG_SYS_MMC_ENV_DEV 0 +#endif + +__weak int mmc_get_env_dev (void ) +{ +return CONFIG_SYS_MMC_ENV_DEV ; +} +#if CONFIG_IS_ENABLED (OF_CONTROL )static inline int mmc_offset_try_partition (const char *str,s64 *val) {struct disk_partition info;struct blk_desc *desc;int len, i, ret; +char dev_str[4 ]; - ret =blk_get_device_by_str ("mmc" ,STR (CONFIG_SYS_MMC_ENV_DEV ), &desc); +snprintf (dev_str,sizeof (dev_str),"%d" ,mmc_get_env_dev ()); + ret =blk_get_device_by_str ("mmc" , dev_str, &desc);if (ret <0 )return (ret);
@@ -114,11 +125,6 @@ __weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)return 0 ; } -__weak int mmc_get_env_dev (void ) -{ -return CONFIG_SYS_MMC_ENV_DEV ; -} -#ifdef CONFIG_SYS_MMC_ENV_PART __weak uint mmc_get_env_part (struct mmc *mmc) {
Signature · 1 line
2.17.1
PATCH RESEND 1/3 env: mmc: allow support of mmc_get_env_dev with OF_CONTROL
Quoted 5 lines · Patrick Delaunay
Use the weak function
mmc_get_env_devinmmc_offset_try_partitionfunction to allow dynamic selection of mmc device to use and no more use directly the defineCONFIG_SYS_MMC_ENV_DEV.Signed-off-by Patrick Delaunay <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200727/7eb5c468/attachment.sig>
PATCH RESEND 2/3 env: mmc: correct the offset returned by mmc_offset_try_partition
In reply to Patrick DelaunayThe output of the function mmc_offset_try_partition must be a byte offset in mmc and not a multiple of blksz.
This function is used in mmc_offset(), called by mmc_get_env_addr() and the offset is used in write_env(), erase_env() and read_env().
In these function, blk_start = offset / mmc->read_bl_len or /write_bl_len so this offset is not a multiple of blksz.
---
env/mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
env/mmc.c +2 -2
@@ -56,10 +56,10 @@ static inline int mmc_offset_try_partition(const char *str, s64 *val) }/* round up to info.blksz */ - len = (CONFIG_ENV_SIZE + info.blksz -1 ) & ~(info.blksz -1 ); + len =DIV_ROUND_UP (CONFIG_ENV_SIZE , info.blksz);/* use the top of the partion for the environment */ - *val = (info.start + info.size -1 ) - len / info.blksz; + *val = (info.start + info.size - len) * info.blksz;return 0 ; }
Signature · 1 line
2.17.1
PATCH RESEND 2/3 env: mmc: correct the offset returned by mmc_offset_try_partition
Quoted 10 lines · Patrick Delaunay
The output of the function
mmc_offset_try_partitionmust be a byte offset in mmc and not a multiple of blksz.This function is used in
mmc_offset(), called bymmc_get_env_addr()and the offset is used inwrite_env(),erase_env()andread_env().In these function,
blk_start= offset /mmc->read_bl_lenor /write_bl_len so this offset is not a multiple of blksz.Signed-off-by Patrick Delaunay <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200727/d322f384/attachment.sig>
PATCH RESEND 3/3 env: mmc: add redundancy support in mmc_offset_try_partition
In reply to Patrick DelaunayManage 2 copy at the end of the partition selected by config "u-boot,mmc-env-partition" to save the U-Boot environment, with CONFIG_ENV_SIZE and 2*CONFIG_ENV_SIZE offset.
This patch allows to support redundancy (CONFIG_ENV_OFFSET_REDUND).
---
env/mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
env/mmc.c +3 -3
@@ -34,7 +34,7 @@ __weak int mmc_get_env_dev(void) }#if CONFIG_IS_ENABLED (OF_CONTROL ) -static inline int mmc_offset_try_partition (const char *str,s64 *val) +static inline int mmc_offset_try_partition (const char *str,int copy,s64 *val) {struct disk_partition info;struct blk_desc *desc;
@@ -59,7 +59,7 @@ static inline int mmc_offset_try_partition(const char *str, s64 *val) len =DIV_ROUND_UP (CONFIG_ENV_SIZE , info.blksz);/* use the top of the partion for the environment */ - *val = (info.start + info.size - len) * info.blksz; + *val = (info.start + info.size - (1 + copy) * len) * info.blksz;return 0 ; }
@@ -84,7 +84,7 @@ static inline s64 mmc_offset(int copy) str =fdtdec_get_config_string (gd->fdt_blob, dt_prop.partition);if (str) {/* try to place the environment at end of the partition */ - err =mmc_offset_try_partition (str, &val); + err =mmc_offset_try_partition (str, copy, &val);if (!err)return val; }
Signature · 1 line
2.17.1
PATCH RESEND 3/3 env: mmc: add redundancy support in mmc_offset_try_partition
Quoted 7 lines · Patrick Delaunay
Manage 2 copy at the end of the partition selected by config "u-boot,mmc-env-partition" to save the U-Boot environment, with
CONFIG_ENV_SIZEand 2*CONFIG_ENV_SIZE offset.This patch allows to support redundancy (
CONFIG_ENV_OFFSET_REDUND).Signed-off-by Patrick Delaunay <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200727/0dd3e44d/attachment.sig>