Files
eternalwrt-mt798x/package/boot/uboot-mediatek/patches/220-cmd-env-readmem.patch
T
Shiji YangandDaniel Golle b6ecbb0374 uboot-mediatek: update to v2026.04
Remove upstreamed patches:
  001-pinctrl-mediatek-MT7981-fix-GPIO9-register-map.patch [1]
  010-clk-mediatek-mt7622-fix-infracfg-and-pericfg-clock-o.patch [2]

We also need to backport two new patches from v2026.07-rc2 to address
the yaml build error[3] and MT7621 boot issue[4].

[1] https://github.com/u-boot/u-boot/commit/a1d1fc8d8c8699d80e1b9ab3214752e5882d3740
[2] https://github.com/u-boot/u-boot/commit/52d84fccfd7d8b99e91a70192eec8e0379d63b4b
[3] https://github.com/u-boot/u-boot/commit/8ef8dee4f3a2b2021decfefd853dbd2a1632b77f
[4] https://github.com/u-boot/u-boot/commit/de79075f0f6b8795d1f9e30ff36435583b1a119a
Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
2026-06-12 13:55:41 +01:00

117 lines
2.9 KiB
Diff

--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -732,6 +732,12 @@ config CMD_ENV_EXISTS
Check if a variable is defined in the environment for use in
shell scripting.
+config CMD_ENV_READMEM
+ bool "env readmem"
+ default y
+ help
+ Store memory content into environment variable.
+
config CMD_ENV_CALLBACK
bool "env callbacks - print callbacks and their associated variables"
help
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -273,6 +273,60 @@ static int do_env_ask(struct cmd_tbl *cm
}
#endif
+#if defined(CONFIG_CMD_ENV_READMEM)
+int do_env_readmem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ char varstr[CONFIG_SYS_CBSIZE];
+ const void *buf;
+ char *local_args[4];
+ ulong addr, bytes = 6;
+ int hexdump = 0;
+
+ /*
+ * Check the syntax:
+ *
+ * readmem [-b] name address [size]
+ */
+ if (argc < 3)
+ return CMD_RET_USAGE;
+
+ local_args[0] = argv[0];
+
+ if (!strncmp(argv[1], "-b", 3))
+ hexdump = 1;
+
+ local_args[1] = argv[hexdump + 1];
+ local_args[2] = varstr;
+ local_args[3] = NULL;
+
+ addr = simple_strtoul(argv[hexdump + 2], NULL, 16);
+
+ if (!hexdump)
+ bytes = simple_strtoul(argv[hexdump + 3], NULL, 16);
+
+ if (bytes < 1)
+ return 1;
+
+ if ((hexdump * 3) * bytes >= CONFIG_SYS_CBSIZE)
+ return 1;
+
+ buf = map_sysmem(addr, bytes);
+ if (!buf)
+ return 1;
+
+ if (hexdump) {
+ sprintf(varstr, "%pM", buf);
+ } else {
+ memcpy(varstr, buf, bytes);
+ varstr[bytes] = '\0';
+ }
+ unmap_sysmem(buf);
+
+ /* Continue calling setenv code */
+ return env_do_env_set(flag, 3, local_args, H_INTERACTIVE);
+}
+#endif
+
#if defined(CONFIG_CMD_ENV_CALLBACK)
static int print_static_binding(const char *var_name, const char *callback_name,
void *priv)
@@ -1095,6 +1149,9 @@ static struct cmd_tbl cmd_env_sub[] = {
U_BOOT_CMD_MKENT(load, 1, 0, do_env_load, "", ""),
#endif
U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_env_print, "", ""),
+#if defined(CONFIG_CMD_ENV_READMEM)
+ U_BOOT_CMD_MKENT(readmem, CONFIG_SYS_MAXARGS, 3, do_env_readmem, "", ""),
+#endif
#if defined(CONFIG_CMD_RUN)
U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""),
#endif
@@ -1179,6 +1236,9 @@ U_BOOT_LONGHELP(env,
#if defined(CONFIG_CMD_NVEDIT_EFI)
"env print -e [-guid guid] [-n] [name ...] - print UEFI environment\n"
#endif
+#if defined(CONFIG_CMD_ENV_READMEM)
+ "env readmem [-b] name address size - read variable from memory\n"
+#endif
#if defined(CONFIG_CMD_RUN)
"env run var [...] - run commands in an environment variable\n"
#endif
@@ -1287,6 +1347,17 @@ U_BOOT_CMD(
);
#endif
+#if defined(CONFIG_CMD_ENV_READMEM)
+U_BOOT_CMD_COMPLETE(
+ readmem, CONFIG_SYS_MAXARGS, 3, do_env_readmem,
+ "get environment variable from memory address",
+ "[-b] name address size\n"
+ " - store memory address to env variable\n"
+ " \"-b\": read binary ethaddr",
+ var_complete
+);
+#endif
+
#if defined(CONFIG_CMD_RUN)
U_BOOT_CMD_COMPLETE(
run, CONFIG_SYS_MAXARGS, 1, do_run,