Commit 62ef060d authored by Angus Ainslie's avatar Angus Ainslie

Merge branch 'load-env-from-bootpart' into 'devkit-wip'

Load env from eMMC boot partition

Closes librem5-devkit-tools#10

See merge request !8
parents 900ac7e7 ef26ef16
......@@ -16,6 +16,7 @@
#include <fdt_support.h>
#include <fsl_wdog.h>
#include <generated/version_autogenerated.h>
#include <mmc.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -409,6 +410,18 @@ int mmc_get_env_dev(void)
return board_mmc_get_env_dev(devno);
}
#ifdef CONFIG_SYS_MMC_ENV_PART
__weak uint board_mmc_get_env_part(struct mmc *mmc)
{
return CONFIG_SYS_MMC_ENV_PART;
}
uint mmc_get_env_part(struct mmc *mmc)
{
return board_mmc_get_env_part(mmc);
}
#endif
#ifdef CONFIG_SERIAL_TAG
void get_board_serial(struct tag_serialnr *serialnr)
{
......
......@@ -12,4 +12,25 @@ config SYS_CONFIG_NAME
config M4_LOAD_DDR_TRAINING
bool "Use the M4 to load the DDR training firmware"
config LOAD_ENV_FROM_MMC_BOOT_PARTITION
bool "Load the environment from the MMC partition U-boot started from"
default N
help
Load/save the U-boot environment from/to the partition the eMMC
is set to boot from.
The boot partition selection is a persistent value set in the
eMMC EXTCSD register using the "mmc partconf" U-boot command.
When this option is enabled, U-boot will determine the MMC
partition to use depending on the value stored in the
PARTITION_CONFIG byte of the EXTCSD register.
When disabled, U-boot will use the partition specified in the
CONFIG_SYS_MMC_ENV_PART define in the board config.
For this option to have any effect, your board config file must
define CONFIG_ENV_IS_IN_MMC, and set appropriate values to
CONFIG_SYS_MMC_ENV_DEV and CONFIG_SYS_MMC_ENV_PART.
endif
......@@ -298,6 +298,16 @@ int board_mmc_get_env_dev(int devno)
return devno;
}
#ifdef CONFIG_LOAD_ENV_FROM_MMC_BOOT_PARTITION
uint board_mmc_get_env_part(struct mmc *mmc)
{
uint part = (mmc->part_config >> 3) & PART_ACCESS_MASK;
if (part == 7)
part = 0;
return part;
}
#endif
int board_late_init(void)
{
struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
......
......@@ -195,11 +195,12 @@
(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
#define CONFIG_ENV_OVERWRITE
#define CONFIG_ENV_OFFSET (64 * SZ_64K)
#define CONFIG_ENV_SIZE 0x2000
#define CONFIG_ENV_OFFSET ((4 * SZ_1M) - (CONFIG_ENV_SIZE))
#define CONFIG_ENV_IS_IN_MMC
#define CONFIG_SYS_MMC_ENV_DEV 1 /* USDHC2 */
#define CONFIG_MMCROOT "/dev/mmcblk1p2" /* USDHC2 */
#define CONFIG_SYS_MMC_ENV_DEV 0 /* USDHC1 */
#define CONFIG_SYS_MMC_ENV_PART 1 /* boot1 */
#define CONFIG_MMCROOT "/dev/mmcblk0p2" /* USDHC1 */
/* Size of malloc() pool */
#define CONFIG_SYS_MALLOC_LEN ((CONFIG_ENV_SIZE + (2*1024)) * 1024)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment