Re: [U-Boot] [PATCH V2 2/4] common: env_mmc: support loading env from different cards
Hi Peng, On 03/02/2016 02:01, Peng Fan wrote: > Hi Stefano, > > On Tue, Feb 02, 2016 at 08:46:09PM +0100, Stefano Babic wrote: >> Hi Peng, >> >> On 17/12/2015 05:43, Peng Fan wrote: >>> Some boards support booting from different SD card slots. >>> For example, mx6dpsabresd board supports booting from SD2, >>> SD3, EMMC4, using different boot switch. And the index >>> numbers are SD2(0), SD3(1), EMMC4(2). >>> But CONFIG_SYS_MMC_ENV_DEV is hardcoded to 1(for SD3), so when >>> booting from SD2(using 0), uboot complains "MMC: no card present", >>> since there is no card in SD3 slot. >>> >>> This patch introduces a weak function which still returns >>> CONFIG_SYS_MMC_ENV_DEV to avoid break other boards. Then >>> different boards can implement mmc_get_env_devno to read >>> env from the correct sd/emmc. >>> >>> Signed-off-by: Peng Fan >>> Cc: Stefano Babic >>> Cc: Simon Glass >>> Cc: Tim Harvey >>> Cc: Hans de Goede >>> --- >>> >> >> Tom sets this patch as deferred - then applying the rest of the series >> makes no sense. Patchset should be rechecked later after next release. > > Could you please check these three patches. I may missed to use V3, but still > used V2. > The three patches are new for the env no. > > https://patchwork.ozlabs.org/patch/574586/ > https://patchwork.ozlabs.org/patch/574587/ > https://patchwork.ozlabs.org/patch/574588/ > I have not tested, but they looks fine - I am picking them up before my PR. Best regards, Stefano Babic -- = DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V2 2/4] common: env_mmc: support loading env from different cards
Hi Stefano, On Tue, Feb 02, 2016 at 08:46:09PM +0100, Stefano Babic wrote: >Hi Peng, > >On 17/12/2015 05:43, Peng Fan wrote: >> Some boards support booting from different SD card slots. >> For example, mx6dpsabresd board supports booting from SD2, >> SD3, EMMC4, using different boot switch. And the index >> numbers are SD2(0), SD3(1), EMMC4(2). >> But CONFIG_SYS_MMC_ENV_DEV is hardcoded to 1(for SD3), so when >> booting from SD2(using 0), uboot complains "MMC: no card present", >> since there is no card in SD3 slot. >> >> This patch introduces a weak function which still returns >> CONFIG_SYS_MMC_ENV_DEV to avoid break other boards. Then >> different boards can implement mmc_get_env_devno to read >> env from the correct sd/emmc. >> >> Signed-off-by: Peng Fan >> Cc: Stefano Babic >> Cc: Simon Glass >> Cc: Tim Harvey >> Cc: Hans de Goede >> --- >> > >Tom sets this patch as deferred - then applying the rest of the series >makes no sense. Patchset should be rechecked later after next release. Could you please check these three patches. I may missed to use V3, but still used V2. The three patches are new for the env no. https://patchwork.ozlabs.org/patch/574586/ https://patchwork.ozlabs.org/patch/574587/ https://patchwork.ozlabs.org/patch/574588/ Thanks, Peng > >Best regards, >Stefano Babic >> Changes V2: >> none. >> >> common/env_mmc.c | 22 ++ >> include/mmc.h| 1 + >> 2 files changed, 15 insertions(+), 8 deletions(-) >> >> diff --git a/common/env_mmc.c b/common/env_mmc.c >> index 9639822..857e20c 100644 >> --- a/common/env_mmc.c >> +++ b/common/env_mmc.c >> @@ -63,6 +63,11 @@ int env_init(void) >> return 0; >> } >> >> +__weak int mmc_get_env_devno(void) >> +{ >> +return CONFIG_SYS_MMC_ENV_DEV; >> +} >> + >> #ifdef CONFIG_SYS_MMC_ENV_PART >> __weak uint mmc_get_env_part(struct mmc *mmc) >> { >> @@ -72,7 +77,7 @@ __weak uint mmc_get_env_part(struct mmc *mmc) >> static int mmc_set_env_part(struct mmc *mmc) >> { >> uint part = mmc_get_env_part(mmc); >> -int dev = CONFIG_SYS_MMC_ENV_DEV; >> +int dev = mmc_get_env_devno(); >> int ret = 0; >> >> #ifdef CONFIG_SPL_BUILD >> @@ -108,7 +113,7 @@ static const char *init_mmc_for_env(struct mmc *mmc) >> static void fini_mmc_for_env(struct mmc *mmc) >> { >> #ifdef CONFIG_SYS_MMC_ENV_PART >> -int dev = CONFIG_SYS_MMC_ENV_DEV; >> +int dev = mmc_get_env_devno(); >> >> #ifdef CONFIG_SPL_BUILD >> dev = 0; >> @@ -127,7 +132,7 @@ static inline int write_env(struct mmc *mmc, unsigned >> long size, >> blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len; >> blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len; >> >> -n = mmc->block_dev.block_write(CONFIG_SYS_MMC_ENV_DEV, blk_start, >> +n = mmc->block_dev.block_write(mmc_get_env_devno(), blk_start, >> blk_cnt, (u_char *)buffer); >> >> return (n == blk_cnt) ? 0 : -1; >> @@ -140,7 +145,8 @@ static unsigned char env_flags; >> int saveenv(void) >> { >> ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1); >> -struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); >> +int mmc_env_devno = mmc_get_env_devno(); >> +struct mmc *mmc = find_mmc_device(mmc_env_devno); >> u32 offset; >> int ret, copy = 0; >> const char *errmsg; >> @@ -168,7 +174,7 @@ int saveenv(void) >> } >> >> printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "", >> - CONFIG_SYS_MMC_ENV_DEV); >> + mmc_env_devno); >> if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) { >> puts("failed\n"); >> ret = 1; >> @@ -192,7 +198,7 @@ static inline int read_env(struct mmc *mmc, unsigned >> long size, >> unsigned long offset, const void *buffer) >> { >> uint blk_start, blk_cnt, n; >> -int dev = CONFIG_SYS_MMC_ENV_DEV; >> +int dev = mmc_get_env_devno(); >> >> #ifdef CONFIG_SPL_BUILD >> dev = 0; >> @@ -216,7 +222,7 @@ void env_relocate_spec(void) >> int crc1_ok = 0, crc2_ok = 0; >> env_t *ep; >> int ret; >> -int dev = CONFIG_SYS_MMC_ENV_DEV; >> +int dev = mmc_get_env_devno(); >> const char *errmsg = NULL; >> >> ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1); >> @@ -302,7 +308,7 @@ void env_relocate_spec(void) >> struct mmc *mmc; >> u32 offset; >> int ret; >> -int dev = CONFIG_SYS_MMC_ENV_DEV; >> +int dev = mmc_get_env_devno(); >> const char *errmsg; >> >> #ifdef CONFIG_SPL_BUILD >> diff --git a/include/mmc.h b/include/mmc.h >> index cda9a19..e70aedb 100644 >> --- a/include/mmc.h >> +++ b/include/mmc.h >> @@ -475,6 +475,7 @@ void board_mmc_power_init(void); >> int board_mmc_init(bd_t *bis); >> int cpu_mmc_init(bd_t *bis); >> int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr); >> +int mmc_get_env_devno(void); >> >> struct pci_device_id; >> >> > >-- >
Re: [U-Boot] [PATCH V2 2/4] common: env_mmc: support loading env from different cards
Hi Peng, On 17/12/2015 05:43, Peng Fan wrote: > Some boards support booting from different SD card slots. > For example, mx6dpsabresd board supports booting from SD2, > SD3, EMMC4, using different boot switch. And the index > numbers are SD2(0), SD3(1), EMMC4(2). > But CONFIG_SYS_MMC_ENV_DEV is hardcoded to 1(for SD3), so when > booting from SD2(using 0), uboot complains "MMC: no card present", > since there is no card in SD3 slot. > > This patch introduces a weak function which still returns > CONFIG_SYS_MMC_ENV_DEV to avoid break other boards. Then > different boards can implement mmc_get_env_devno to read > env from the correct sd/emmc. > > Signed-off-by: Peng Fan > Cc: Stefano Babic > Cc: Simon Glass > Cc: Tim Harvey > Cc: Hans de Goede > --- > Tom sets this patch as deferred - then applying the rest of the series makes no sense. Patchset should be rechecked later after next release. Best regards, Stefano Babic > Changes V2: > none. > > common/env_mmc.c | 22 ++ > include/mmc.h| 1 + > 2 files changed, 15 insertions(+), 8 deletions(-) > > diff --git a/common/env_mmc.c b/common/env_mmc.c > index 9639822..857e20c 100644 > --- a/common/env_mmc.c > +++ b/common/env_mmc.c > @@ -63,6 +63,11 @@ int env_init(void) > return 0; > } > > +__weak int mmc_get_env_devno(void) > +{ > + return CONFIG_SYS_MMC_ENV_DEV; > +} > + > #ifdef CONFIG_SYS_MMC_ENV_PART > __weak uint mmc_get_env_part(struct mmc *mmc) > { > @@ -72,7 +77,7 @@ __weak uint mmc_get_env_part(struct mmc *mmc) > static int mmc_set_env_part(struct mmc *mmc) > { > uint part = mmc_get_env_part(mmc); > - int dev = CONFIG_SYS_MMC_ENV_DEV; > + int dev = mmc_get_env_devno(); > int ret = 0; > > #ifdef CONFIG_SPL_BUILD > @@ -108,7 +113,7 @@ static const char *init_mmc_for_env(struct mmc *mmc) > static void fini_mmc_for_env(struct mmc *mmc) > { > #ifdef CONFIG_SYS_MMC_ENV_PART > - int dev = CONFIG_SYS_MMC_ENV_DEV; > + int dev = mmc_get_env_devno(); > > #ifdef CONFIG_SPL_BUILD > dev = 0; > @@ -127,7 +132,7 @@ static inline int write_env(struct mmc *mmc, unsigned > long size, > blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len; > blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len; > > - n = mmc->block_dev.block_write(CONFIG_SYS_MMC_ENV_DEV, blk_start, > + n = mmc->block_dev.block_write(mmc_get_env_devno(), blk_start, > blk_cnt, (u_char *)buffer); > > return (n == blk_cnt) ? 0 : -1; > @@ -140,7 +145,8 @@ static unsigned char env_flags; > int saveenv(void) > { > ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1); > - struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); > + int mmc_env_devno = mmc_get_env_devno(); > + struct mmc *mmc = find_mmc_device(mmc_env_devno); > u32 offset; > int ret, copy = 0; > const char *errmsg; > @@ -168,7 +174,7 @@ int saveenv(void) > } > > printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "", > -CONFIG_SYS_MMC_ENV_DEV); > +mmc_env_devno); > if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) { > puts("failed\n"); > ret = 1; > @@ -192,7 +198,7 @@ static inline int read_env(struct mmc *mmc, unsigned long > size, > unsigned long offset, const void *buffer) > { > uint blk_start, blk_cnt, n; > - int dev = CONFIG_SYS_MMC_ENV_DEV; > + int dev = mmc_get_env_devno(); > > #ifdef CONFIG_SPL_BUILD > dev = 0; > @@ -216,7 +222,7 @@ void env_relocate_spec(void) > int crc1_ok = 0, crc2_ok = 0; > env_t *ep; > int ret; > - int dev = CONFIG_SYS_MMC_ENV_DEV; > + int dev = mmc_get_env_devno(); > const char *errmsg = NULL; > > ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1); > @@ -302,7 +308,7 @@ void env_relocate_spec(void) > struct mmc *mmc; > u32 offset; > int ret; > - int dev = CONFIG_SYS_MMC_ENV_DEV; > + int dev = mmc_get_env_devno(); > const char *errmsg; > > #ifdef CONFIG_SPL_BUILD > diff --git a/include/mmc.h b/include/mmc.h > index cda9a19..e70aedb 100644 > --- a/include/mmc.h > +++ b/include/mmc.h > @@ -475,6 +475,7 @@ void board_mmc_power_init(void); > int board_mmc_init(bd_t *bis); > int cpu_mmc_init(bd_t *bis); > int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr); > +int mmc_get_env_devno(void); > > struct pci_device_id; > > -- = DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://li