[U-Boot] [question] need help with mmc-env-addr
Frank Wunderlich
FrankWu at gmx.de
Thu Oct 25 09:59:08 UTC 2018
Hi,
i hope questions are also allowed on this mailing list :)
i try to port environment-saving from 2014-04 to 2018-11...and in 2014 i see that an offset of 1 MB is added to address when booting from SD-Card. I have the boot-device-detection ready, but i'm unsure how to implement the env-adress...
i know i can override mmc_get_env_addr (because it's weak), but original function uses an inline-function mmc_offset which i cannot use outside (without removing the inline-statement and/or adding function to mmc.h).
this is the function call i'm talking about:
https://github.com/frank-w/u-boot/blob/bpi-r2_v2/env/mmc.c#L113
here i want to add it:
https://github.com/frank-w/u-boot/blob/bpi-r2_v2/board/mediatek/mt7623/mt7623_rfb.c
and this is how it's implemented in 2014 uboot:
https://github.com/BPI-SINOVOIP/BPI-R2-bsp/commit/0b7eb9e24a66d405970aff1b466bb50b21f925b8
especially this mmc_offset is differently implemented depending on CONFIG_IS_ENABLED(OF_CONTROL)...if this is set, there are accesses to Device-tree...imho i have not (yet) enabled this (what does it exactly?).
if this flag is not used i want to implement the function like this:
int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
{
s64 offset = CONFIG_ENV_OFFSET;
#ifdef CONFIG_ENV_OFFSET_REDUND
if (copy)
offset = CONFIG_ENV_OFFSET_REDUND;
#endif
if (offset < 0)
offset += mmc->capacity;
//If mmc is SD, then set offset 1Mb
if(mmc_get_boot_dev() == 1)
*env_addr = offset + 0x100000;
else
*env_addr = offset;
return 0;
}
maybe the question "why adding an additional offset??" this is because on SD-Card on BPI-R2 there are additional headers for booting (MMC_BOOT and BRLYT-signature). for more see here: https://www.fw-web.de/dokuwiki/doku.php?id=en/bpi-r2/storage#extended_boot-headers
i hope i have explained enough...
what is the best way to implement it? imho propagate the mmc_offset-functions to outside but this changes common code (why is this function "hidden" and can/should this be changed?). i don't want to create too much redundant code (reimplement mmc_offset) and the 1MB-offset should also be defined in board-specific area (in opposition to 2014-code).
regards Frank
More information about the U-Boot
mailing list