diff options
Diffstat (limited to 'commands')
-rw-r--r-- | commands/Kconfig | 16 | ||||
-rw-r--r-- | commands/Makefile | 2 | ||||
-rw-r--r-- | commands/dmesg.c | 100 | ||||
-rw-r--r-- | commands/firmwareload.c | 66 |
4 files changed, 184 insertions, 0 deletions
diff --git a/commands/Kconfig b/commands/Kconfig index 0563e63f0a..6528bf76c7 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -84,6 +84,13 @@ config CMD_DEVINFO If called with a device path being the argument, devinfo shows more default information about this device and its parameters. +config CMD_DMESG + tristate + prompt "dmesg" + select LOGBUF + help + Print or control the log message buffer. + config CMD_DRVINFO tristate default y @@ -1905,6 +1912,15 @@ config CMD_BAREBOX_UPDATE -y autom. use 'yes' when asking confirmations -f LEVEL set force level +config CMD_FIRMWARELOAD + bool + select FIRMWARE + prompt "firmwareload" + help + Provides the "firmwareload" command which deals with devices which need + firmware to work. It is also used to upload firmware to FPGA devices. + + config CMD_LINUX_EXEC bool "linux exec" depends on LINUX diff --git a/commands/Makefile b/commands/Makefile index f5ecbe6f1e..b1cdf331c4 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_CMD_IOMEM) += iomemport.o obj-$(CONFIG_CMD_LINUX_EXEC) += linux_exec.o obj-$(CONFIG_CMD_AUTOMOUNT) += automount.o obj-$(CONFIG_CMD_GLOBAL) += global.o +obj-$(CONFIG_CMD_DMESG) += dmesg.o obj-$(CONFIG_CMD_BASENAME) += basename.o obj-$(CONFIG_CMD_DIRNAME) += dirname.o obj-$(CONFIG_CMD_READLINK) += readlink.o @@ -104,3 +105,4 @@ obj-$(CONFIG_CMD_LSPCI) += lspci.o obj-$(CONFIG_CMD_IMD) += imd.o obj-$(CONFIG_CMD_HWCLOCK) += hwclock.o obj-$(CONFIG_CMD_USBGADGET) += usbgadget.o +obj-$(CONFIG_CMD_FIRMWARELOAD) += firmwareload.o diff --git a/commands/dmesg.c b/commands/dmesg.c new file mode 100644 index 0000000000..b2bb334e24 --- /dev/null +++ b/commands/dmesg.c @@ -0,0 +1,100 @@ +/* + * dmesg.c - barebox logbuffer handling + * + * Copyright (c) 2014 Sascha Hauer <s.hauer@pengutronix.de>, 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 version 2 + * as published by the Free Software Foundation. + * + * 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 <malloc.h> +#include <command.h> +#include <globalvar.h> +#include <environment.h> +#include <getopt.h> +#include <clock.h> + +static int do_dmesg(int argc, char *argv[]) +{ + int opt, i; + int delete_buf = 0, emit = 0; + unsigned flags = 0; + + while ((opt = getopt(argc, argv, "ctde")) > 0) { + switch (opt) { + case 'c': + delete_buf = 1; + break; + case 't': + flags |= BAREBOX_LOG_PRINT_TIME; + break; + case 'd': + flags |= BAREBOX_LOG_DIFF_TIME; + break; + case 'e': + emit = 1; + break; + default: + return COMMAND_ERROR_USAGE; + } + } + + if (emit) { + char *buf; + int len = 0; + + for (i = optind; i < argc; i++) + len += strlen(argv[i]) + 1; + + buf = malloc(len + 2); + if (!buf) + return -ENOMEM; + + len = 0; + + for (i = optind; i < argc; i++) + len += sprintf(buf + len, "%s ", argv[i]); + + *(buf + len) = '\n'; + *(buf + len + 1) = 0; + + pr_info(buf); + + free(buf); + + return 0; + } + + log_print(flags); + + if (delete_buf) + log_clean(10); + + return 0; +} + +BAREBOX_CMD_HELP_START(dmesg) +BAREBOX_CMD_HELP_TEXT("Options:") +BAREBOX_CMD_HELP_OPT ("-c", "Delete messages after printing them") +BAREBOX_CMD_HELP_OPT ("-d", "Show a time delta to the last message") +BAREBOX_CMD_HELP_OPT ("-e <msg>", "Emit a log message") +BAREBOX_CMD_HELP_OPT ("-t", "Show timestamp informations") +BAREBOX_CMD_HELP_END + +BAREBOX_CMD_START(dmesg) + .cmd = do_dmesg, + BAREBOX_CMD_DESC("Print or control log messages") + BAREBOX_CMD_OPTS("[-cdet]") + BAREBOX_CMD_GROUP(CMD_GRP_INFO) + BAREBOX_CMD_HELP(cmd_dmesg_help) +BAREBOX_CMD_END diff --git a/commands/firmwareload.c b/commands/firmwareload.c new file mode 100644 index 0000000000..a2596951a7 --- /dev/null +++ b/commands/firmwareload.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2013 Juergen Beisert <kernel@pengutronix.de>, Pengutronix + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * 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 <getopt.h> +#include <firmware.h> + +static int do_firmwareload(int argc, char *argv[]) +{ + int ret, opt; + const char *name = NULL, *firmware; + struct firmware_mgr *mgr; + + while ((opt = getopt(argc, argv, "t:l")) > 0) { + switch (opt) { + case 't': + name = optarg; + break; + case 'l': + firmwaremgr_list_handlers(); + return 0; + default: + return COMMAND_ERROR_USAGE; + } + } + + if (!(argc - optind)) + return COMMAND_ERROR_USAGE; + + firmware = argv[optind]; + + mgr = firmwaremgr_find(name); + + if (!mgr) { + printf("No such programming handler found: %s\n", + name ? name : "default"); + return 1; + } + + ret = firmwaremgr_load_file(mgr, firmware); + + return ret; +} + +BAREBOX_CMD_HELP_START(firmwareload) +BAREBOX_CMD_HELP_TEXT("Options:") +BAREBOX_CMD_HELP_OPT("-t <target>", "define the firmware handler by name\n") +BAREBOX_CMD_HELP_OPT("-l\t", "list devices capable of firmware loading\n") +BAREBOX_CMD_HELP_END + +BAREBOX_CMD_START(firmwareload) + .cmd = do_firmwareload, + BAREBOX_CMD_DESC("Program a firmware file into a device") + BAREBOX_CMD_HELP(cmd_firmwareload_help) +BAREBOX_CMD_END |