cmd: add "showlayout" command to get available mtd layouts in fdt

This commit is contained in:
hanwckf
2023-07-15 20:58:36 +08:00
parent 07ad801d40
commit 0608830f8b
3 changed files with 37 additions and 0 deletions

View File

@@ -2600,5 +2600,10 @@ config CMD_GL_BTN
bool "GL-iNet button check command"
depends on BUTTON
default n
config CMD_SHOW_MTD_LAYOUT
bool "Show mtd layout command"
depends on OF_LIBFDT
default n
endmenu

View File

@@ -210,6 +210,8 @@ obj-$(CONFIG_CMD_SCP03) += scp03.o
obj-$(CONFIG_CMD_GL_BTN) += glbtn.o
obj-$(CONFIG_CMD_SHOW_MTD_LAYOUT) += showlayout.o
obj-$(CONFIG_ARM) += arm/
obj-$(CONFIG_RISCV) += riscv/
obj-$(CONFIG_SANDBOX) += sandbox/

View File

@@ -0,0 +1,30 @@
#include <common.h>
#include <command.h>
#include <dm/ofnode.h>
static int do_showlayout(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
ofnode node, layout;
node = ofnode_path("/mtd-layout");
if (ofnode_valid(node) && ofnode_get_child_count(node)) {
ofnode_for_each_subnode(layout, node) {
printf("mtd label: %s, mtdids: %s, mtdparts: %s\n",
ofnode_read_string(layout, "label"),
ofnode_read_string(layout, "mtdids"),
ofnode_read_string(layout, "mtdparts"));
}
} else {
printf("get mtd layout failed!\n");
}
return CMD_RET_SUCCESS;
}
U_BOOT_CMD(
showlayout, 2, 0, do_showlayout,
"Show mtd layout",
""
);