Skip to contentSkip to conversation

usb: ums: wait for usb cable connection before enter ums mode

PATCH New Przemyslaw Marczak 2 participants 6 messages Jan 7, 2014 – Jan 13, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: ums: wait for usb cable connection before enter ums mode

Before this change ums mode can not be entered when device was using the same usb port for usb/uart communication. Switching USB cable from UART to USB always causes ums exit.

---
 common/cmd_usb_mass_storage.c |   24 ++++++++++++++++++++++++
 include/usb_mass_storage.h    |    3 +++
 2 files changed, 27 insertions(+)
common/cmd_usb_mass_storage.c +24 -0
index 99487f4..5f557d5 100644
@@ -42,6 +42,30 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 
 	g_dnl_register("ums");
 
+	/* Timeout unit: seconds */
+	int cable_ready_timeout = UMS_CABLE_READY_TIMEOUT;
+
+	if (!usb_cable_connected()) {
+		puts("Please connect USB cable.\n");
+
+		while (!usb_cable_connected()) {
+			if (ctrlc()) {
+				puts("\rCTRL+C - Operation aborted.\n");
+				goto exit;
+			}
+			if (!cable_ready_timeout) {
+				puts("\rUSB cable not detected.\n" \
+				     "Command exit.\n");
+				goto exit;
+			}
+
+			printf("\rAuto exit in: %.2d s.", cable_ready_timeout);
+			mdelay(1000);
+			cable_ready_timeout--;
+		}
+		puts("\r\n");
+	}
+
 	while (1) {
 		usb_gadget_handle_interrupts();
 
include/usb_mass_storage.h +3 -0
index 9df3adc..058dcf1 100644
@@ -20,6 +20,9 @@
 #define UMS_NUM_SECTORS		0
 #endif
 
+/* Wait at maximum 60 seconds for cable connection */
+#define UMS_CABLE_READY_TIMEOUT	60
+
 struct ums {
 	int (*read_sector)(struct ums *ums_dev,
 			   ulong start, lbaint_t blkcnt, void *buf);
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 usb: ums: wait for usb cable connection before enter ums mode

Hello everyone,

Quoted 52 lines · Przemyslaw Marczak

Before this change ums mode can not be entered when device was using the same usb port for usb/uart communication. Switching USB cable from UART to USB always causes ums exit.

---
  common/cmd_usb_mass_storage.c |   24 ++++++++++++++++++++++++
  include/usb_mass_storage.h    |    3 +++
  2 files changed, 27 insertions(+)
common/cmd_usb_mass_storage.c +24 -0
index 99487f4..5f557d5 100644
@@ -42,6 +42,30 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 
  	g_dnl_register("ums");
 
+	/* Timeout unit: seconds */
+	int cable_ready_timeout = UMS_CABLE_READY_TIMEOUT;
+
+	if (!usb_cable_connected()) {
+		puts("Please connect USB cable.\n");
+
+		while (!usb_cable_connected()) {
+			if (ctrlc()) {
+				puts("\rCTRL+C - Operation aborted.\n");
+				goto exit;
+			}
+			if (!cable_ready_timeout) {
+				puts("\rUSB cable not detected.\n" \
+				     "Command exit.\n");
+				goto exit;
+			}
+
+			printf("\rAuto exit in: %.2d s.", cable_ready_timeout);
+			mdelay(1000);
+			cable_ready_timeout--;
+		}
+		puts("\r\n");
+	}
+
  	while (1) {
  		usb_gadget_handle_interrupts();
 
include/usb_mass_storage.h +0 -0
index 9df3adc..058dcf1 100644

include/usb_mass_storage.h line 28

Quoted 9 lines
include/usb_mass_storage.h +3 -0
@@ -20,6 +20,9 @@
  #define UMS_NUM_SECTORS		0
  #endif
 
+/* Wait at maximum 60 seconds for cable connection */
+#define UMS_CABLE_READY_TIMEOUT	60
+
  struct ums {
  	int (*read_sector)(struct ums *ums_dev,
  			   ulong start, lbaint_t blkcnt, void *buf);

I was send some very useful fix to the ums. It is required for users who are using the same usb port for USB and UART purposes. Without this fix such users just can't use ums because it will always exit to prompt when user change the cable.

So I have few questions...
Marek, could you review this patch?
And what about the release, are you going to send pull request before the release?
If not, then is it possible to apply this patch directly to u-boot/master by Tom Rini?

Thank you,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#2 lore raw

PATCH 1/1 usb: ums: wait for usb cable connection before enter ums mode

Quoted 67 lines · Przemyslaw Marczak

Hello everyone,

Quoted 64 lines · Przemyslaw Marczak

Before this change ums mode can not be entered when device was using the same usb port for usb/uart communication. Switching USB cable from UART to USB always causes ums exit.

---

  common/cmd_usb_mass_storage.c |   24 ++++++++++++++++++++++++
  include/usb_mass_storage.h    |    3 +++
  2 files changed, 27 insertions(+)
(quoted diff) +0 -0

b/common/cmd_usb_mass_storage.c index 99487f4..5f557d5 100644

common/cmd_usb_mass_storage.c +24 -0
@@ -42,6 +42,30 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 
  	g_dnl_register("ums");
 
+	/* Timeout unit: seconds */
+	int cable_ready_timeout = UMS_CABLE_READY_TIMEOUT;
+
+	if (!usb_cable_connected()) {
+		puts("Please connect USB cable.\n");
+
+		while (!usb_cable_connected()) {
+			if (ctrlc()) {
+				puts("\rCTRL+C - Operation aborted.\n");
+				goto exit;
+			}
+			if (!cable_ready_timeout) {
+				puts("\rUSB cable not detected.\n" \
+				     "Command exit.\n");
+				goto exit;
+			}
+
+			printf("\rAuto exit in: %.2d s.", cable_ready_timeout);
+			mdelay(1000);
+			cable_ready_timeout--;
+		}
+		puts("\r\n");
+	}
+
 
  	while (1) {
 
  		usb_gadget_handle_interrupts();
include/usb_mass_storage.h +3 -0
index 9df3adc..058dcf1 100644
@@ -20,6 +20,9 @@
 
  #define UMS_NUM_SECTORS		0
  #endif
 
+/* Wait at maximum 60 seconds for cable connection */
+#define UMS_CABLE_READY_TIMEOUT	60
+
 
  struct ums {
Quoted 8 lines
Quoted 3 lines

int (*read_sector)(struct ums *ums_dev,

ulong start, lbaint_t blkcnt, void *buf);

I was send some very useful fix to the ums. It is required for users who are using the same usb port for USB and UART purposes. Without this fix such users just can't use ums because it will always exit to prompt when user change the cable.

Can you please share the schematic of such a cable in public? How does this "sharing" of USB and UART work? I am very curious here :-)

Quoted 2 lines

So I have few questions...
Marek, could you review this patch?

On it!

Quoted 4 lines

And what about the release, are you going to send pull request before the release?
If not, then is it possible to apply this patch directly to u-boot/master by Tom Rini?

PR will happen once I am through the load of patches in my mailbox.

#3 lore raw

PATCH 1/1 usb: ums: wait for usb cable connection before enter ums mode

Hello,

Quoted 70 lines · Marek Vasut
Quoted 69 lines · Przemyslaw Marczak

Hello everyone,

Quoted 66 lines · Przemyslaw Marczak

Before this change ums mode can not be entered when device was using the same usb port for usb/uart communication. Switching USB cable from UART to USB always causes ums exit.

---

   common/cmd_usb_mass_storage.c |   24 ++++++++++++++++++++++++
   include/usb_mass_storage.h    |    3 +++
   2 files changed, 27 insertions(+)
(quoted diff) +0 -0

b/common/cmd_usb_mass_storage.c index 99487f4..5f557d5 100644

common/cmd_usb_mass_storage.c +24 -0
@@ -42,6 +42,30 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 
   	g_dnl_register("ums");
 
+	/* Timeout unit: seconds */
+	int cable_ready_timeout = UMS_CABLE_READY_TIMEOUT;
+
+	if (!usb_cable_connected()) {
+		puts("Please connect USB cable.\n");
+
+		while (!usb_cable_connected()) {
+			if (ctrlc()) {
+				puts("\rCTRL+C - Operation aborted.\n");
+				goto exit;
+			}
+			if (!cable_ready_timeout) {
+				puts("\rUSB cable not detected.\n" \
+				     "Command exit.\n");
+				goto exit;
+			}
+
+			printf("\rAuto exit in: %.2d s.", cable_ready_timeout);
+			mdelay(1000);
+			cable_ready_timeout--;
+		}
+		puts("\r\n");
+	}
+
 
   	while (1) {
 
   		usb_gadget_handle_interrupts();
include/usb_mass_storage.h +3 -0
index 9df3adc..058dcf1 100644
@@ -20,6 +20,9 @@
 
   #define UMS_NUM_SECTORS		0
   #endif
 
+/* Wait at maximum 60 seconds for cable connection */
+#define UMS_CABLE_READY_TIMEOUT	60
+
 
   struct ums {

int (*read_sector)(struct ums *ums_dev,

Quoted 8 lines
Quoted 6 lines
Quoted 1 line
   			   ulong start, lbaint_t blkcnt, void *buf);

I was send some very useful fix to the ums. It is required for users who are using the same usb port for USB and UART purposes. Without this fix such users just can't use ums because it will always exit to prompt when user change the cable.

Can you please share the schematic of such a cable in public?

Unfortunately I am not allowed to share such information.

Quoted 2 lines

How does this
"sharing" of USB and UART work? I am very curious here :-)

Regarding the USB sharing explanation - please refer to FSA9480 data sheet. It is available on the Internet.

I can also recommend looking into newest kernel code support for Trats2 device.

Quoted 12 lines
Quoted 2 lines

So I have few questions...
Marek, could you review this patch?

On it!

Quoted 4 lines

And what about the release, are you going to send pull request before the release?
If not, then is it possible to apply this patch directly to u-boot/master by Tom Rini?

PR will happen once I am through the load of patches in my mailbox.

Thank you for patch apply.

Regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#4 lore raw

PATCH 1/1 usb: ums: wait for usb cable connection before enter ums mode

Quoted 80 lines · Przemyslaw Marczak

Hello,

Quoted 77 lines · Marek Vasut
Quoted 75 lines · Przemyslaw Marczak

Hello everyone,

Quoted 64 lines · Przemyslaw Marczak

Before this change ums mode can not be entered when device was using the same usb port for usb/uart communication. Switching USB cable from UART to USB always causes ums exit.

---

   common/cmd_usb_mass_storage.c |   24 ++++++++++++++++++++++++
   include/usb_mass_storage.h    |    3 +++
   2 files changed, 27 insertions(+)
(quoted diff) +0 -0

b/common/cmd_usb_mass_storage.c index 99487f4..5f557d5 100644

common/cmd_usb_mass_storage.c +24 -0
@@ -42,6 +42,30 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 
   	g_dnl_register("ums");
 
+	/* Timeout unit: seconds */
+	int cable_ready_timeout = UMS_CABLE_READY_TIMEOUT;
+
+	if (!usb_cable_connected()) {
+		puts("Please connect USB cable.\n");
+
+		while (!usb_cable_connected()) {
+			if (ctrlc()) {
+				puts("\rCTRL+C - Operation aborted.\n");
+				goto exit;
+			}
+			if (!cable_ready_timeout) {
+				puts("\rUSB cable not detected.\n" \
+				     "Command exit.\n");
+				goto exit;
+			}
+
+			printf("\rAuto exit in: %.2d s.", cable_ready_timeout);
+			mdelay(1000);
+			cable_ready_timeout--;
+		}
+		puts("\r\n");
+	}
+
 
   	while (1) {
 
   		usb_gadget_handle_interrupts();
include/usb_mass_storage.h +3 -0
index 9df3adc..058dcf1 100644
@@ -20,6 +20,9 @@
 
   #define UMS_NUM_SECTORS		0
   #endif
 
+/* Wait at maximum 60 seconds for cable connection */
+#define UMS_CABLE_READY_TIMEOUT	60
+
 
   struct ums {
Quoted 3 lines

int (*read_sector)(struct ums *ums_dev,

   			   ulong start, lbaint_t blkcnt, void *buf);

I was send some very useful fix to the ums. It is required for users who are using the same usb port for USB and UART purposes. Without this fix such users just can't use ums because it will always exit to prompt when user change the cable.

Quoted 3 lines
Quoted 1 line

Can you please share the schematic of such a cable in public?

Unfortunately I am not allowed to share such information.

Is the trats2 so similar to galaxy SIII or what ? :)

Quoted 5 lines
Quoted 2 lines

How does this
"sharing" of USB and UART work? I am very curious here :-)

Regarding the USB sharing explanation - please refer to FSA9480 data sheet. It is available on the Internet.

Thanks.

Quoted 2 lines

I can also recommend looking into newest kernel code support for Trats2 device.

Yes, this is helpful, thanks!

Quoted 15 lines
Quoted 11 lines
Quoted 2 lines

So I have few questions...
Marek, could you review this patch?

On it!

Quoted 4 lines

And what about the release, are you going to send pull request before the release?
If not, then is it possible to apply this patch directly to u-boot/master by Tom Rini?

PR will happen once I am through the load of patches in my mailbox.

Thank you for patch apply.

Regards,

Applied
#5 lore raw

PATCH 1/1 usb: ums: wait for usb cable connection before enter ums mode

In reply to Przemyslaw Marczak
Quoted 5 lines · Przemyslaw Marczak

Before this change ums mode can not be entered when device was using the same usb port for usb/uart communication. Switching USB cable from UART to USB always causes ums exit.

Applied, thanks.

Best regards,
Marek Vasut