cmd: add "showlayout" command to get available mtd layouts in fdt
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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/
|
||||
|
||||
30
uboot-mtk-20220606/cmd/showlayout.c
Normal file
30
uboot-mtk-20220606/cmd/showlayout.c
Normal 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",
|
||||
""
|
||||
);
|
||||
Reference in New Issue
Block a user