See doc/usage/cmd/meminfo.rst for more information.
+config CMD_MEMSIZE
+ bool "memsize"
+ depends on CMD_MEMINFO
+ help
+ Get RAM via command for use in scripts. Print or assign decimal value
+ in MiB to environment variable.
+
config CMD_MEMORY
bool "md, mm, nm, mw, cp, cmp, base, loop"
default y
#include <bootstage.h>
#include <command.h>
#include <display_options.h>
+#include <env.h>
#include <lmb.h>
#include <malloc.h>
#include <mapmem.h>
#include <asm/global_data.h>
+#include <linux/sizes.h>
DECLARE_GLOBAL_DATA_PTR;
return 0;
}
+#ifdef CONFIG_CMD_MEMSIZE
+static int do_mem_size(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ u64 memsize = gd->ram_size / SZ_1M;
+
+ if (argc > 1)
+ return env_set_ulong(argv[1], memsize);
+ else
+ printf("%lld MiB\n", memsize);
+
+ return 0;
+}
+#endif /* CONFIG_CMD_MEMSIZE */
+
U_BOOT_CMD(
meminfo, 1, 1, do_meminfo,
"display memory information",
""
);
+
+#ifdef CONFIG_CMD_MEMSIZE
+U_BOOT_CMD(
+ memsize, 2, 1, do_mem_size,
+ "get detected ram size in MiB, optional set env variable with value",
+ "[envvar]"
+);
+#endif /* CONFIG_CMD_MEMSIZE */