summaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-08-11 13:43:03 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-08-11 13:43:03 +0200
commitad4fa274907bbc78ebabb015b4351d5f9226f081 (patch)
tree3eb033a3d6bedb50459ea0181e5180e1531d00e8 /commands
parent3fcf4400a7b051bdbe9fc175b88336519099ff22 (diff)
parent3a0f44a7839d475c58720c4091d5e008215cd166 (diff)
downloadbarebox-ad4fa274907bbc78ebabb015b4351d5f9226f081.tar.gz
Merge branch 'for-next/misc'
Diffstat (limited to 'commands')
-rw-r--r--commands/Kconfig1
-rw-r--r--commands/boot.c19
-rw-r--r--commands/devinfo.c2
-rw-r--r--commands/of_dump.c15
4 files changed, 29 insertions, 8 deletions
diff --git a/commands/Kconfig b/commands/Kconfig
index 69d76a9c80..3e21dc4c05 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -367,6 +367,7 @@ config CMD_BOOT
BOOTSRC can be:
- a filename under /env/boot/
- a full path to a boot script
+ - a full path to a bootspec entry
- a device name
- a partition name under /dev/
- a full path to a directory which
diff --git a/commands/boot.c b/commands/boot.c
index 18f4e36ec7..5fd59f8642 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -28,13 +28,14 @@ static int do_boot(int argc, char *argv[])
char *freep = NULL;
int opt, ret = 0, do_list = 0, do_menu = 0;
int dryrun = 0, verbose = 0, timeout = -1;
+ unsigned default_menu_entry = 0;
struct bootentries *entries;
struct bootentry *entry;
void *handle;
const char *name;
char *(*next)(void *);
- while ((opt = getopt(argc, argv, "vldmt:w:")) > 0) {
+ while ((opt = getopt(argc, argv, "vldmM:t:w:")) > 0) {
switch (opt) {
case 'v':
verbose++;
@@ -45,6 +46,16 @@ static int do_boot(int argc, char *argv[])
case 'd':
dryrun = 1;
break;
+ case 'M':
+ /* To simplify scripting, an empty string is treated as 1 */
+ if (*optarg == '\0') {
+ default_menu_entry = 1;
+ } else {
+ ret = kstrtouint(optarg, 0, &default_menu_entry);
+ if (ret)
+ return ret;
+ }
+ fallthrough;
case 'm':
do_menu = 1;
break;
@@ -104,7 +115,7 @@ static int do_boot(int argc, char *argv[])
if (do_list)
bootsources_list(entries);
else if (do_menu)
- bootsources_menu(entries, timeout);
+ bootsources_menu(entries, default_menu_entry, timeout);
ret = 0;
out:
@@ -122,6 +133,7 @@ BAREBOX_CMD_HELP_TEXT("")
BAREBOX_CMD_HELP_TEXT("BOOTSRC can be:")
BAREBOX_CMD_HELP_TEXT("- a filename under /env/boot/")
BAREBOX_CMD_HELP_TEXT("- a full path to a boot script")
+BAREBOX_CMD_HELP_TEXT("- a full path to a bootspec entry")
BAREBOX_CMD_HELP_TEXT("- a device name")
BAREBOX_CMD_HELP_TEXT("- a partition name under /dev/")
BAREBOX_CMD_HELP_TEXT("- a full path to a directory which")
@@ -136,6 +148,7 @@ BAREBOX_CMD_HELP_OPT ("-v","Increase verbosity")
BAREBOX_CMD_HELP_OPT ("-d","Dryrun. See what happens but do no actually boot")
BAREBOX_CMD_HELP_OPT ("-l","List available boot sources")
BAREBOX_CMD_HELP_OPT ("-m","Show a menu with boot options")
+BAREBOX_CMD_HELP_OPT ("-M INDEX","Show a menu with boot options with entry INDEX preselected")
BAREBOX_CMD_HELP_OPT ("-w SECS","Start watchdog with timeout SECS before booting")
BAREBOX_CMD_HELP_OPT ("-t SECS","specify timeout in SECS")
BAREBOX_CMD_HELP_END
@@ -143,7 +156,7 @@ BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(boot)
.cmd = do_boot,
BAREBOX_CMD_DESC("boot from script, device, ...")
- BAREBOX_CMD_OPTS("[-vdlmwt] [BOOTSRC...]")
+ BAREBOX_CMD_OPTS("[-vdlmMwt] [BOOTSRC...]")
BAREBOX_CMD_GROUP(CMD_GRP_BOOT)
BAREBOX_CMD_HELP(cmd_boot_help)
BAREBOX_CMD_END
diff --git a/commands/devinfo.c b/commands/devinfo.c
index 32fd55ebd5..e171ecc62c 100644
--- a/commands/devinfo.c
+++ b/commands/devinfo.c
@@ -104,7 +104,7 @@ static int do_devinfo(int argc, char *argv[])
#ifdef CONFIG_OFDEVICE
if (dev->device_node) {
printf("Device node: %s\n", dev->device_node->full_name);
- of_print_nodes(dev->device_node, 0);
+ of_print_nodes(dev->device_node, 0, ~0);
}
#endif
}
diff --git a/commands/of_dump.c b/commands/of_dump.c
index 6f36b31514..c2ca8485cd 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -39,9 +39,10 @@ static int do_of_dump(int argc, char *argv[])
char *dtbfile = NULL;
size_t size;
const char *nodename;
+ unsigned maxpropsize = ~0;
int names_only = 0, properties_only = 0;
- while ((opt = getopt(argc, argv, "Ff:np")) > 0) {
+ while ((opt = getopt(argc, argv, "Ff:npP:")) > 0) {
switch (opt) {
case 'f':
dtbfile = optarg;
@@ -55,6 +56,11 @@ static int do_of_dump(int argc, char *argv[])
case 'p':
properties_only = 1;
break;
+ case 'P':
+ ret = kstrtouint(optarg, 0, &maxpropsize);
+ if (ret)
+ return ret;
+ break;
default:
return COMMAND_ERROR_USAGE;
}
@@ -120,9 +126,9 @@ static int do_of_dump(int argc, char *argv[])
if (names_only && !properties_only)
of_print_nodenames(node);
else if (properties_only && !names_only)
- of_print_properties(node);
+ of_print_properties(node, maxpropsize);
else
- of_print_nodes(node, 0);
+ of_print_nodes(node, 0, maxpropsize);
out:
if (of_free)
@@ -137,12 +143,13 @@ BAREBOX_CMD_HELP_OPT ("-f dtb", "work on dtb instead of internal devicetree")
BAREBOX_CMD_HELP_OPT ("-F", "return fixed devicetree")
BAREBOX_CMD_HELP_OPT ("-n", "Print node names only, no properties")
BAREBOX_CMD_HELP_OPT ("-p", "Print properties only, no child nodes")
+BAREBOX_CMD_HELP_OPT ("-P len", "print only len property bytes")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(of_dump)
.cmd = do_of_dump,
BAREBOX_CMD_DESC("dump devicetree nodes")
- BAREBOX_CMD_OPTS("[-fFnp] [NODE]")
+ BAREBOX_CMD_OPTS("[-fFnpP] [NODE]")
BAREBOX_CMD_GROUP(CMD_GRP_MISC)
BAREBOX_CMD_COMPLETE(devicetree_file_complete)
BAREBOX_CMD_HELP(cmd_of_dump_help)