aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini2023-11-25 12:34:23 -0500
committerTom Rini2023-11-25 12:34:23 -0500
commit129d6a0d87b7f19b85dc0a007f7050ce973fd019 (patch)
treedce8a44891dd5789bf620245a768469d53e689ef
parent1682d97db9aa5bbfc8c5b9f26bd1454e6a9a0ccb (diff)
parent8a0d07807abb5370fe879321c7f1d22fdda3255f (diff)
Merge tag 'u-boot-dfu-next-20231124' of https://source.denx.de/u-boot/custodians/u-boot-dfu into next
u-boot-dfu-next-20231124 - Make dfu entity name size configurable in KConfig - Implement start-stop for UMS (graceful shutdown via eject) - Improve help messages for cmd/bind - Improve help message for udc bind failures
-rw-r--r--cmd/Kconfig2
-rw-r--r--cmd/bind.c4
-rw-r--r--drivers/dfu/Kconfig9
-rw-r--r--drivers/usb/gadget/Kconfig1
-rw-r--r--drivers/usb/gadget/f_mass_storage.c7
-rw-r--r--drivers/usb/gadget/udc/udc-core.c13
-rw-r--r--include/dfu.h5
7 files changed, 39 insertions, 2 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 9ebea76c2ce..4569c06c750 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -977,7 +977,7 @@ config CMD_BCB
config CMD_BIND
bool "bind/unbind - Bind or unbind a device to/from a driver"
depends on DM
- default y if USB_ETHER
+ imply CMD_DM
help
Bind or unbind a device to/from a driver from the command line.
This is useful in situations where a device may be handled by several
diff --git a/cmd/bind.c b/cmd/bind.c
index 4d1b7885e60..be0d4d2a711 100644
--- a/cmd/bind.c
+++ b/cmd/bind.c
@@ -246,6 +246,8 @@ U_BOOT_CMD(
"Bind a device to a driver",
"<node path> <driver>\n"
"bind <class> <index> <driver>\n"
+ "Use 'dm tree' to list all devices registered in the driver model,\n"
+ "their path, class, index and current driver.\n"
);
U_BOOT_CMD(
@@ -254,4 +256,6 @@ U_BOOT_CMD(
"<node path>\n"
"unbind <class> <index>\n"
"unbind <class> <index> <driver>\n"
+ "Use 'dm tree' to list all devices registered in the driver model,\n"
+ "their path, class, index and current driver.\n"
);
diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index 8771678ca5a..0360d9da142 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -112,5 +112,14 @@ config SYS_DFU_MAX_FILE_SIZE
the buffer once we've been given the whole file. Define
this to the maximum filesize (in bytes) for the buffer.
If undefined it defaults to the CONFIG_SYS_DFU_DATA_BUF_SIZE.
+
+config DFU_NAME_MAX_SIZE
+ int "Size of the name to be added in dfu entity"
+ default 32
+ depends on DFU
+ help
+ This value is used to maximum size. If name is longer than default size,
+ we need to change the proper maximum size.
+
endif
endmenu
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 4eccc5e3370..c72a8047635 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -17,6 +17,7 @@ menuconfig USB_GADGET
bool "USB Gadget Support"
depends on DM
select DM_USB
+ imply CMD_BIND
help
USB is a master/slave protocol, organized with one master
host (such as a PC) controlling up to 127 peripheral devices.
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 1d17331cb03..c725aed3f62 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -327,6 +327,7 @@ struct fsg_common {
unsigned int short_packet_received:1;
unsigned int bad_lun_okay:1;
unsigned int running:1;
+ unsigned int eject:1;
int thread_wakeup_needed;
struct completion thread_notifier;
@@ -669,6 +670,10 @@ static int sleep_thread(struct fsg_common *common)
}
if (k == 10) {
+ /* Handle START-STOP UNIT */
+ if (common->eject)
+ return -EPIPE;
+
/* Handle CTRL+C */
if (ctrlc())
return -EPIPE;
@@ -1325,6 +1330,8 @@ static int do_start_stop(struct fsg_common *common)
return -EINVAL;
}
+ common->eject = 1;
+
return 0;
}
diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
index eb0b35969ce..ba658d92296 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -323,6 +323,7 @@ err1:
int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
{
struct usb_udc *udc = NULL;
+ unsigned int udc_count = 0;
int ret;
if (!driver || !driver->bind || !driver->setup)
@@ -330,12 +331,22 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
mutex_lock(&udc_lock);
list_for_each_entry(udc, &udc_list, list) {
+ udc_count++;
+
/* For now we take the first one */
if (!udc->driver)
goto found;
}
- printf("couldn't find an available UDC\n");
+ if (!udc_count)
+ printf("No UDC available in the system\n");
+ else
+ /* When this happens, users should 'unbind <class> <index>'
+ * using the output of 'dm tree' and looking at the line right
+ * after the USB peripheral/device controller.
+ */
+ printf("All UDCs in use (%d available), use the unbind command\n",
+ udc_count);
mutex_unlock(&udc_lock);
return -ENODEV;
found:
diff --git a/include/dfu.h b/include/dfu.h
index 68b5ca46ce5..2f42781888a 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -98,7 +98,12 @@ struct virt_internal_data {
int dev_num;
};
+
+#if defined(CONFIG_DFU_NAME_MAX_SIZE)
+#define DFU_NAME_SIZE CONFIG_DFU_NAME_MAX_SIZE
+#else
#define DFU_NAME_SIZE 32
+#endif
#ifndef DFU_DEFAULT_POLL_TIMEOUT
#define DFU_DEFAULT_POLL_TIMEOUT 0
#endif