summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongjin Kim <tobetter@gmail.com>2022-04-22 08:59:26 +0300
committerDongjin Kim <tobetter@gmail.com>2022-04-22 09:01:52 +0300
commit0fd92ea4c6ef4f7f88baaf4b2c1741d5369c34f6 (patch)
tree056bd7eafebe21dc8f876b5106e058c602ab727f
parent09ffccce617877e1fcb3ab443a11c203b216d0ee (diff)
downloadu-boot-0fd92ea4c6ef4f7f88baaf4b2c1741d5369c34f6.tar.xz
ODROID-M1: load environment from SPI flash at very early
In order to use an environment value at early stage in U-Boot procedure, specifically earlier than a kernel device tree blob is proceed, the environment value must be loaded and imported. Signed-off-by: Dongjin Kim <tobetter@gmail.com> Change-Id: I147b2b37f3d1706e22a27083549eff7a8815064e
-rw-r--r--board/hardkernel/odroid-m1/odroid-m1.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/board/hardkernel/odroid-m1/odroid-m1.c b/board/hardkernel/odroid-m1/odroid-m1.c
index 6fefc3d849..212d48efca 100644
--- a/board/hardkernel/odroid-m1/odroid-m1.c
+++ b/board/hardkernel/odroid-m1/odroid-m1.c
@@ -18,6 +18,7 @@
#include <rksfc.h>
#endif
#include "../../../drivers/video/drm/rockchip_display.h"
+#include <environment.h>
extern int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
extern struct rockchip_logo_cache *find_or_alloc_logo_cache(const char *bmp);
@@ -72,6 +73,8 @@ int board_early_init_r(void)
struct blk_desc *dev_desc = rockchip_get_bootdev();
int ret = -EINVAL;
char buf[16];
+ char cmd[256];
+ char env[CONFIG_ENV_SIZE];
int n;
#if defined(CONFIG_RKSFC_NOR)
@@ -83,7 +86,6 @@ int board_early_init_r(void)
snprintf(buf, sizeof(buf), "%d:%d", dev_desc->devnum, n);
if (file_exists("mmc", buf, "ODROIDBIOS.BIN", FS_TYPE_ANY)) {
- char cmd[256];
snprintf(cmd, sizeof(cmd),
"load mmc %s $cramfsaddr ODROIDBIOS.BIN", buf);
ret = run_command(cmd, 0);
@@ -92,11 +94,14 @@ int board_early_init_r(void)
}
}
- if (ret) {
- run_command_list( "sf probe\n"
- "sf read $cramfsaddr 0x400000 0xc00000",
- -1, 0);
- }
+ run_command("sf probe", 0);
+ if (ret)
+ run_command("sf read $cramfsaddr 0x400000 0xc00000", 0);
+
+ snprintf(cmd, sizeof(cmd), "sf read 0x%p 0x%p 0x%p\n",
+ env, (void*)CONFIG_ENV_OFFSET, (void*)CONFIG_ENV_SIZE);
+ if (run_command(cmd, 0) == 0)
+ env_import(env, 1);
return 0;
}