diff options
Diffstat (limited to 'commands')
-rw-r--r-- | commands/Kconfig | 13 | ||||
-rw-r--r-- | commands/Makefile | 1 | ||||
-rw-r--r-- | commands/barebox-update.c | 1 | ||||
-rw-r--r-- | commands/cp.c | 1 | ||||
-rw-r--r-- | commands/crc.c | 1 | ||||
-rw-r--r-- | commands/dfu.c | 15 | ||||
-rw-r--r-- | commands/edit.c | 12 | ||||
-rw-r--r-- | commands/exec.c | 1 | ||||
-rw-r--r-- | commands/help.c | 2 | ||||
-rw-r--r-- | commands/imd.c | 60 | ||||
-rw-r--r-- | commands/insmod.c | 1 | ||||
-rw-r--r-- | commands/linux16.c | 1 | ||||
-rw-r--r-- | commands/lspci.c | 2 | ||||
-rw-r--r-- | commands/of_dump.c | 1 | ||||
-rw-r--r-- | commands/oftree.c | 3 | ||||
-rw-r--r-- | commands/readf.c | 1 | ||||
-rw-r--r-- | commands/saveenv.c | 33 | ||||
-rw-r--r-- | commands/tftp.c | 1 | ||||
-rw-r--r-- | commands/trigger.c | 5 | ||||
-rw-r--r-- | commands/ubiformat.c | 1 | ||||
-rw-r--r-- | commands/uimage.c | 1 |
21 files changed, 133 insertions, 24 deletions
diff --git a/commands/Kconfig b/commands/Kconfig index 6a75f85f89..8ee0805407 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -148,6 +148,15 @@ config CMD_IOMEM Show information about iomem/ioport usage. Pendant to 'cat /proc/iomem' and 'cat /proc/ioports' under Linux. +config CMD_IMD + tristate + prompt "imd" + select IMD + help + barebox images can have metadata in them which contains information + like the barebox version and the build time. Say yes here to get the + imd command which can extract that information from images. + config CMD_MEMINFO tristate prompt "meminfo" @@ -1867,7 +1876,7 @@ endmenu -menu "Miscelleanous" +menu "Miscellaneous" config CMD_2048 tristate @@ -1984,7 +1993,7 @@ config CMD_TIME Note: This command depends on COMMAND being interruptible, otherwise the timer may overrun resulting in incorrect results -# end Miscelleanous commands +# end Miscellaneous commands endmenu diff --git a/commands/Makefile b/commands/Makefile index 44dd9d49a9..ca0289782e 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -100,4 +100,5 @@ obj-$(CONFIG_CMD_MENUTREE) += menutree.o obj-$(CONFIG_CMD_2048) += 2048.o obj-$(CONFIG_CMD_REGULATOR) += regulator.o obj-$(CONFIG_CMD_LSPCI) += lspci.o +obj-$(CONFIG_CMD_IMD) += imd.o obj-$(CONFIG_CMD_HWCLOCK) += hwclock.o diff --git a/commands/barebox-update.c b/commands/barebox-update.c index a24dc3ef4d..92e0efab6a 100644 --- a/commands/barebox-update.c +++ b/commands/barebox-update.c @@ -17,6 +17,7 @@ */ #include <common.h> #include <command.h> +#include <libfile.h> #include <getopt.h> #include <malloc.h> #include <errno.h> diff --git a/commands/cp.c b/commands/cp.c index 1a5675405e..af7a3d4dc0 100644 --- a/commands/cp.c +++ b/commands/cp.c @@ -26,6 +26,7 @@ #include <malloc.h> #include <libgen.h> #include <getopt.h> +#include <libfile.h> /** * @param[in] argc Argument count from command line diff --git a/commands/crc.c b/commands/crc.c index 7c2936c23c..9b6a3e2a4b 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -22,6 +22,7 @@ #include <fs.h> #include <getopt.h> #include <malloc.h> +#include <libfile.h> #include <environment.h> static int crc_from_file(const char* file, ulong *crc) diff --git a/commands/dfu.c b/commands/dfu.c index 354625260d..7f78f3bbc2 100644 --- a/commands/dfu.c +++ b/commands/dfu.c @@ -172,12 +172,15 @@ out: BAREBOX_CMD_HELP_START(dfu) BAREBOX_CMD_HELP_TEXT("Turn's the USB host into DFU mode (Device Firmware Mode) and accepts") -BAREBOX_CMD_HELP_TEXT("a new firmware. The destination is described by DESC in the this format:") -BAREBOX_CMD_HELP_TEXT(" DEVICE(NAME)[src]...") -BAREBOX_CMD_HELP_TEXT("Specify the '(') and ')' literal, the [] however denote this optional modes:") -BAREBOX_CMD_HELP_TEXT("- 's' safe mode (download the complete image before flashing)") -BAREBOX_CMD_HELP_TEXT("- 'r' readback of the firmware is allowed") -BAREBOX_CMD_HELP_TEXT("- 'c' the file will be created (for use with regular files)") +BAREBOX_CMD_HELP_TEXT("a new firmware. The destination is described by DESC in the format") +BAREBOX_CMD_HELP_TEXT("") +BAREBOX_CMD_HELP_TEXT("\tDEVICE(NAME)[src]...") +BAREBOX_CMD_HELP_TEXT("") +BAREBOX_CMD_HELP_TEXT("Here '(' and ')' are literal characters. The '[' and ']' however denote") +BAREBOX_CMD_HELP_TEXT("one of the following optional modes:") +BAREBOX_CMD_HELP_TEXT("'s': safe mode (download the complete image before flashing); ") +BAREBOX_CMD_HELP_TEXT("'r': readback of the firmware is allowed; ") +BAREBOX_CMD_HELP_TEXT("'c': the file will be created (for use with regular files).") BAREBOX_CMD_HELP_TEXT("") BAREBOX_CMD_HELP_TEXT("Options:") BAREBOX_CMD_HELP_OPT ("-m STR", "Manufacturer string (barebox)") diff --git a/commands/edit.c b/commands/edit.c index 5a2da7d034..b28e2b92a1 100644 --- a/commands/edit.c +++ b/commands/edit.c @@ -21,6 +21,7 @@ #include <fs.h> #include <linux/ctype.h> #include <fcntl.h> +#include <libfile.h> #include <readkey.h> #include <errno.h> #include <xfuncs.h> @@ -379,7 +380,16 @@ static int do_edit(int argc, char *argv[]) return COMMAND_ERROR_USAGE; screenwidth = 80; - screenheight = 25; + + /* + * The EFI simple text output protocol wraps to the next line and scrolls + * down when we write to the right bottom screen position. Reduce the number + * of rows by one to work around this. + */ + if (IS_ENABLED(CONFIG_ARCH_EFI)) + screenheight = 24; + else + screenheight = 25; /* check if we are called as "sedit" instead of "edit" */ if (*argv[0] == 's') { diff --git a/commands/exec.c b/commands/exec.c index 635f65eeb2..7c8934f137 100644 --- a/commands/exec.c +++ b/commands/exec.c @@ -23,6 +23,7 @@ #include <fcntl.h> #include <linux/stat.h> #include <errno.h> +#include <libfile.h> #include <malloc.h> #include <xfuncs.h> diff --git a/commands/help.c b/commands/help.c index 9c33807fad..898533594f 100644 --- a/commands/help.c +++ b/commands/help.c @@ -128,7 +128,7 @@ static int do_help(int argc, char *argv[]) BAREBOX_CMD_HELP_START(help) -BAREBOX_CMD_HELP_TEXT("Without arguments, lists all all commands. With an argument, print help") +BAREBOX_CMD_HELP_TEXT("Without arguments, lists all commands. With an argument, print help") BAREBOX_CMD_HELP_TEXT("about the specified command. If the argument is 'all', then output help") BAREBOX_CMD_HELP_TEXT("for all commands.") BAREBOX_CMD_HELP_TEXT("") diff --git a/commands/imd.c b/commands/imd.c new file mode 100644 index 0000000000..f1a22cef96 --- /dev/null +++ b/commands/imd.c @@ -0,0 +1,60 @@ +/* + * (C) Copyright 2014 Sascha Hauer, Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <common.h> +#include <command.h> +#include <complete.h> +#include <environment.h> +#include <image-metadata.h> + +int imd_command_setenv(const char *variable_name, const char *value) +{ + return setenv(variable_name, value); +} + +static int do_imd(int argc, char *argv[]) +{ + int ret; + + ret = imd_command(argc, argv); + + if (ret == -ENOSYS) + return COMMAND_ERROR_USAGE; + + return ret; +} + +BAREBOX_CMD_HELP_START(imd) +BAREBOX_CMD_HELP_TEXT("extract metadata from barebox binary") +BAREBOX_CMD_HELP_TEXT("") +BAREBOX_CMD_HELP_TEXT("Options:") +BAREBOX_CMD_HELP_OPT ("-t <type>", "only show information of <type>") +BAREBOX_CMD_HELP_OPT ("-n <no>", "for tags with multiple strings only show string <no>") +BAREBOX_CMD_HELP_OPT ("-s VARNAME", "set variable VARNAME instead of showing information") +BAREBOX_CMD_HELP_TEXT("") +BAREBOX_CMD_HELP_TEXT("Without options all information available is printed. Valid types are:") +BAREBOX_CMD_HELP_TEXT("release, build, model, of_compatible") +BAREBOX_CMD_HELP_END + +BAREBOX_CMD_START(imd) + .cmd = do_imd, + BAREBOX_CMD_DESC("extract metadata from barebox binary") + BAREBOX_CMD_OPTS("[nst] FILE") + BAREBOX_CMD_GROUP(CMD_GRP_INFO) + BAREBOX_CMD_HELP(cmd_imd_help) +BAREBOX_CMD_END diff --git a/commands/insmod.c b/commands/insmod.c index 176437ee70..735dde0222 100644 --- a/commands/insmod.c +++ b/commands/insmod.c @@ -3,6 +3,7 @@ #include <module.h> #include <errno.h> #include <fs.h> +#include <libfile.h> #include <malloc.h> static int do_insmod(int argc, char *argv[]) diff --git a/commands/linux16.c b/commands/linux16.c index 594efc7dc2..bb678bdb83 100644 --- a/commands/linux16.c +++ b/commands/linux16.c @@ -24,6 +24,7 @@ #include <environment.h> #include <fs.h> #include <errno.h> +#include <libfile.h> #include <getopt.h> #include <malloc.h> #include <boot.h> diff --git a/commands/lspci.c b/commands/lspci.c index c00b57f894..fdf02691b5 100644 --- a/commands/lspci.c +++ b/commands/lspci.c @@ -46,7 +46,7 @@ static int do_lspci(int argc, char *argv[]) BAREBOX_CMD_START(lspci) .cmd = do_lspci, - BAREBOX_CMD_DESC("Show PCI info") + BAREBOX_CMD_DESC("show PCI info") BAREBOX_CMD_GROUP(CMD_GRP_INFO) BAREBOX_CMD_COMPLETE(empty_complete) BAREBOX_CMD_END diff --git a/commands/of_dump.c b/commands/of_dump.c index cafde07b7c..315dbbae8c 100644 --- a/commands/of_dump.c +++ b/commands/of_dump.c @@ -18,6 +18,7 @@ */ #include <common.h> +#include <libfile.h> #include <fdt.h> #include <of.h> #include <command.h> diff --git a/commands/oftree.c b/commands/oftree.c index 983a0a59ea..8a47c0be58 100644 --- a/commands/oftree.c +++ b/commands/oftree.c @@ -26,6 +26,7 @@ #include <common.h> #include <environment.h> #include <fdt.h> +#include <libfile.h> #include <of.h> #include <command.h> #include <fs.h> @@ -42,7 +43,7 @@ static int do_oftree(int argc, char *argv[]) { struct fdt_header *fdt = NULL; - int size; + size_t size; int opt; int probe = 0; char *load = NULL; diff --git a/commands/readf.c b/commands/readf.c index c8cc574f35..8dd5a2b55a 100644 --- a/commands/readf.c +++ b/commands/readf.c @@ -1,6 +1,7 @@ #include <common.h> #include <command.h> #include <fs.h> +#include <libfile.h> #include <malloc.h> #include <linux/stat.h> #include <linux/ctype.h> diff --git a/commands/saveenv.c b/commands/saveenv.c index 54b6fa1b7b..9da733e722 100644 --- a/commands/saveenv.c +++ b/commands/saveenv.c @@ -18,26 +18,39 @@ #include <common.h> #include <command.h> #include <errno.h> +#include <getopt.h> #include <fs.h> #include <fcntl.h> #include <envfs.h> static int do_saveenv(int argc, char *argv[]) { - int ret; + int ret, opt; + unsigned envfs_flags = 0; char *filename, *dirname; printf("saving environment\n"); - if (argc < 3) + while ((opt = getopt(argc, argv, "z")) > 0) { + switch (opt) { + case 'z': + envfs_flags |= ENVFS_FLAGS_FORCE_BUILT_IN; + break; + } + } + + /* destination and source are given? */ + if (argc == optind + 2) + dirname = argv[optind + 1]; + else dirname = "/env"; + + /* destination only given? */ + if (argc == optind + 1) + filename = argv[optind]; else - dirname = argv[2]; - if (argc < 2) filename = default_environment_path_get(); - else - filename = argv[1]; - ret = envfs_save(filename, dirname); + ret = envfs_save(filename, dirname, envfs_flags); return ret; } @@ -47,15 +60,15 @@ BAREBOX_CMD_HELP_TEXT("Save the files in DIRECTORY to the persistent storage dev BAREBOX_CMD_HELP_TEXT("") BAREBOX_CMD_HELP_TEXT("ENVFS is usually a block in flash but can be any other file. If") BAREBOX_CMD_HELP_TEXT("omitted, DIRECTORY defaults to /env and ENVFS defaults to") -BAREBOX_CMD_HELP_TEXT("/dev/env0. Note that envfs can only handle files, directories are being") -BAREBOX_CMD_HELP_TEXT("skipped silently.") +BAREBOX_CMD_HELP_TEXT("/dev/env0.") +BAREBOX_CMD_HELP_OPT ("-z", "force the built-in default environment at startup") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(saveenv) .cmd = do_saveenv, BAREBOX_CMD_DESC("save environment to persistent storage") - BAREBOX_CMD_OPTS("[ENVFS] [DIRECTORY]") + BAREBOX_CMD_OPTS("[-z] [ENVFS [DIRECTORY]]") BAREBOX_CMD_GROUP(CMD_GRP_ENV) BAREBOX_CMD_HELP(cmd_saveenv_help) BAREBOX_CMD_END diff --git a/commands/tftp.c b/commands/tftp.c index 62b9424cf3..8a3b541382 100644 --- a/commands/tftp.c +++ b/commands/tftp.c @@ -24,6 +24,7 @@ #include <fs.h> #include <net.h> #include <libbb.h> +#include <libfile.h> #define TFTP_MOUNT_PATH "/.tftp_tmp_path" diff --git a/commands/trigger.c b/commands/trigger.c index 17c8411501..b605448a91 100644 --- a/commands/trigger.c +++ b/commands/trigger.c @@ -68,8 +68,9 @@ static int do_trigger(int argc, char *argv[]) break; case LED_COMMAND_DISABLE_TRIGGER: - led_set_trigger(trigger, NULL); - return 0; + ret = led_set_trigger(trigger, NULL); + break; + case LED_COMMAND_SET_TRIGGER: if (argc - optind != 1) return COMMAND_ERROR_USAGE; diff --git a/commands/ubiformat.c b/commands/ubiformat.c index 443d645a5a..df0b801da9 100644 --- a/commands/ubiformat.c +++ b/commands/ubiformat.c @@ -40,6 +40,7 @@ #include <malloc.h> #include <ioctl.h> #include <libbb.h> +#include <libfile.h> #include <linux/mtd/mtd.h> #include <linux/kernel.h> #include <linux/stat.h> diff --git a/commands/uimage.c b/commands/uimage.c index 33523d7e5c..7c2dca41ec 100644 --- a/commands/uimage.c +++ b/commands/uimage.c @@ -7,6 +7,7 @@ #include <malloc.h> #include <errno.h> #include <getopt.h> +#include <libfile.h> static int uimage_fd; |