summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2016-11-11 10:04:31 -0800
committerMax Krummenacher <max.krummenacher@toradex.com>2017-01-18 09:46:24 +0100
commit536464b4e5c705646ee11143e79128bb39f077f9 (patch)
treefe4e31cf2ff644352c256eda9196ec68edd07fd4 /cmd
parentf3d25fc844f7001d1f4ed7e90e53db7f81c029a6 (diff)
cmd: add sdp command
Add new command to start USB Serial Download Protocol (SDP) state machine. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Max Krummenacher <max.krummenacher@toradex.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig7
-rw-r--r--cmd/Makefile1
-rw-r--r--cmd/usb_gadget_sdp.c53
3 files changed, 61 insertions, 0 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index e339d8638a..43b7c82d39 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -409,6 +409,13 @@ config CMD_DFU
Enables the command "dfu" which is used to have U-Boot create a DFU
class device via USB.
+config CMD_USB_SDP
+ bool "sdp"
+ select USB_FUNCTION_SDP
+ help
+ Enables the command "sdp" which is used to have U-Boot emulating the
+ Serial Download Protocol (SDP) via USB.
+
config CMD_USB_MASS_STORAGE
bool "UMS usb mass storage"
help
diff --git a/cmd/Makefile b/cmd/Makefile
index 9c9a9d112b..4b566a1092 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_CMD_FASTBOOT) += fastboot.o
obj-$(CONFIG_CMD_FS_UUID) += fs_uuid.o
obj-$(CONFIG_CMD_USB_MASS_STORAGE) += usb_mass_storage.o
+obj-$(CONFIG_CMD_USB_SDP) += usb_gadget_sdp.o
obj-$(CONFIG_CMD_THOR_DOWNLOAD) += thordown.o
obj-$(CONFIG_CMD_XIMG) += ximg.o
obj-$(CONFIG_YAFFS2) += yaffs2.o
diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
new file mode 100644
index 0000000000..09ddb4f3aa
--- /dev/null
+++ b/cmd/usb_gadget_sdp.c
@@ -0,0 +1,53 @@
+/*
+ * cmd_sdp.c -- sdp command
+ *
+ * Copyright (C) 2016 Toradex
+ * Author: Stefan Agner <stefan.agner@toradex.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <g_dnl.h>
+#include <sdp.h>
+#include <usb.h>
+
+static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ int ret = CMD_RET_SUCCESS;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ char *usb_controller = argv[1];
+ int controller_index = simple_strtoul(usb_controller, NULL, 0);
+ board_usb_init(controller_index, USB_INIT_DEVICE);
+
+ g_dnl_clear_detach();
+ g_dnl_register("usb_dnl_sdp");
+
+ ret = sdp_init();
+ if (ret) {
+ error("SDP init failed: %d", ret);
+ ret = CMD_RET_FAILURE;
+ goto exit;
+ }
+
+ ret = sdp_handle();
+ if (ret) {
+ error("SDP failed: %d", ret);
+ ret = CMD_RET_FAILURE;
+ goto exit;
+ }
+
+exit:
+ g_dnl_unregister();
+
+ return ret;
+}
+
+U_BOOT_CMD(sdp, 2, 1, do_sdp,
+ "Serial Downloader Protocol",
+ "<USB_controller>\n"
+ " - serial downloader protocol via <USB_controller>\n"
+);