diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-10-02 08:54:41 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-10-02 08:54:41 +0200 |
commit | d0064495d3325cb630bc79550d60a4f4eef57e31 (patch) | |
tree | 0011e3237f2501588bc37b286253764a3e855b3c /commands | |
parent | 13f1dedaeea0077554111a0075eeb24f66ceacbd (diff) | |
parent | d0a0e807ab4449aec068b1e86dac85b687f93ea5 (diff) | |
download | barebox-d0064495d3325cb630bc79550d60a4f4eef57e31.tar.gz barebox-d0064495d3325cb630bc79550d60a4f4eef57e31.tar.xz |
Merge branch 'for-next/firmware'
Diffstat (limited to 'commands')
-rw-r--r-- | commands/Kconfig | 9 | ||||
-rw-r--r-- | commands/Makefile | 1 | ||||
-rw-r--r-- | commands/firmwareload.c | 66 |
3 files changed, 76 insertions, 0 deletions
diff --git a/commands/Kconfig b/commands/Kconfig index f0cd8b2ae4..bd09ec2fb5 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -1912,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 608ff5eb40..58e70fee1a 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -104,3 +104,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/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 |