* [U-Boot] SD card on the GuruPlug
@ 2010-10-01 16:17 Ludovic Courtès
2010-10-02 23:12 ` [U-Boot] Troubles accessing a USB mass storage device Ludovic Courtès
[not found] ` <1235049614.358782.1286186899690.JavaMail.root@zmbs1.inria.fr>
0 siblings, 2 replies; 8+ messages in thread
From: Ludovic Courtès @ 2010-10-01 16:17 UTC (permalink / raw)
To: u-boot
Hello,
The GuruPlug has an internal ?SD card reader, which it views as a USB
device:
--8<---------------cut here---------------start------------->8---
Marvell>> usb start
(Re)start USB...
USB: Register 10011 NbrPorts 1
USB EHCI 1.00
scanning bus for devices... 3 USB Device(s) found
scanning bus for storage devices... Device NOT ready
Request Sense returned 02 3A 00
1 Storage Device(s) found
Marvell>> usb tree
Device Tree:
1 Hub (480 Mb/s, 0mA)
| u-boot EHCI Host Controller
|
+-2 Hub (480 Mb/s, 100mA)
| USB2.0 Hub
|
+-3 Mass Storage (480 Mb/s, 500mA)
USB Storage 000000009909
--8<---------------cut here---------------end--------------->8---
However, with a ?SD card in, with a valid MS-DOS partition table, it
apparently fails to read from it:
--8<---------------cut here---------------start------------->8---
Marvell>> usb part
## Unknown partition table
--8<---------------cut here---------------end--------------->8---
Conversely, ?usb part? works as expected with a USB key or USB disk
plugged in.
Does anyone have experience with it? Any idea how I could further debug
the problem?
Thanks,
Ludo?.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] Troubles accessing a USB mass storage device
2010-10-01 16:17 [U-Boot] SD card on the GuruPlug Ludovic Courtès
@ 2010-10-02 23:12 ` Ludovic Courtès
2010-10-04 22:11 ` [U-Boot] [PATCH] usb: Add support for multiple-LUN mass storage devices Ludovic Courtès
[not found] ` <1235049614.358782.1286186899690.JavaMail.root@zmbs1.inria.fr>
1 sibling, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2010-10-02 23:12 UTC (permalink / raw)
To: u-boot
ludo at gnu.org (Ludovic Court?s) writes:
> However, with a ?SD card in, with a valid MS-DOS partition table, it
> apparently fails to read from it:
>
> Marvell>> usb part
> ## Unknown partition table
Further investigation with all the debugging output enabled shows that
it?s the ?test unit ready? command (0x0) that fails:
--8<---------------cut here---------------start------------->8---
COMMAND phase
dir 0 lun 0 cmdlen 12 cmd 0065c1c4 datalen 0 pdata 0065c478
cmd[0] 0x0 cmd[1] 0x0 cmd[2] 0x0 cmd[3] 0x0 cmd[4] 0x0 cmd[5] 0x0 cmd[6] 0x0 cmd[7] 0x0 cmd[8] 0x0 cmd[9] 0x0 cmd[10] 0x0 cmd[11] 0x0
STATUS phase
ptr[0] 0x55 ptr[1] 0x53 ptr[2] 0x42 ptr[3] 0x53 ptr[4] 0x7e ptr[5] 0x0 ptr[6] 0x0 ptr[7] 0x0 ptr[8] 0x0 ptr[9] 0x0 ptr[10] 0x0 ptr[11] 0x0 ptr[12] 0x1
FAILED
COMMAND phase
dir 1 lun 0 cmdlen 12 cmd 0065c1c4 datalen 18 pdata 0065c1d4
cmd[0] 0x3 cmd[1] 0x0 cmd[2] 0x0 cmd[3] 0x0 cmd[4] 0x12 cmd[5] 0x0 cmd[6] 0x0 cmd[7] 0x0 cmd[8] 0x0 cmd[9] 0x0 cmd[10] 0x0 cmd[11] 0x0
DATA phase
pdata[0] 0x70 pdata[1] 0x0 pdata[2] 0x2 pdata[3] 0x0 pdata[4] 0x0 pdata[5] 0x0 pdata[6] 0x0 pdata[7] 0xa pdata[8] 0x0 pdata[9] 0x0 pdata[10] 0x0 pdata[11] 0x0 pdata[12] 0x3a pdata[13] 0x0 pdata[14] 0x0 pdata[15] 0x0 pdata[16] 0x0 pdata[17] 0x0
STATUS phase
ptr[0] 0x55 ptr[1] 0x53 ptr[2] 0x42 ptr[3] 0x53 ptr[4] 0x7f ptr[5] 0x0 ptr[6] 0x0 ptr[7] 0x0 ptr[8] 0x0 ptr[9] 0x0 ptr[10] 0x0 ptr[11] 0x0 ptr[12] 0x0
Request Sense returned 02 3A 00
--8<---------------cut here---------------end--------------->8---
The request sense KCQ can be interpreted as ?Not Ready - Medium Not
Present?, according to
<https://secure.wikimedia.org/wikipedia/en/wiki/KCQ>, despite the fact
that the SD card is actually in (and Linux can successfully read from
it.)
The card reader has USB IDs 05e3:0726 (Genesys Logic).
Any idea how to go further?
Besides, ?usb_request_sense? and ?usb_test_unit_ready? both assume
LUN == 0. Could it be a problem?
Thanks,
Ludo?.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] SD card on the GuruPlug
[not found] ` <1235049614.358782.1286186899690.JavaMail.root@zmbs1.inria.fr>
@ 2010-10-04 14:26 ` Ludovic Courtès
0 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2010-10-04 14:26 UTC (permalink / raw)
To: u-boot
Hi,
Prafulla Wadaskar <prafulla@marvell.com> writes:
> On guruplug+ if the uSD cards are inserted on both the slots (internal and external)
> The USB storage does not gets detected.
Yes, I figured out. I?m preparing a patch that adds support for
multi-LUN USB mass storage devices.
Thanks,
Ludo?.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] usb: Add support for multiple-LUN mass storage devices
2010-10-02 23:12 ` [U-Boot] Troubles accessing a USB mass storage device Ludovic Courtès
@ 2010-10-04 22:11 ` Ludovic Courtès
[not found] ` <26012718.1256010.1286282818170.JavaMail.root@zmbs1.inria.fr>
2010-10-05 20:04 ` [U-Boot] [PATCH v2] " Ludovic Courtès
0 siblings, 2 replies; 8+ messages in thread
From: Ludovic Courtès @ 2010-10-04 22:11 UTC (permalink / raw)
To: u-boot
Hi,
ludo at gnu.org (Ludovic Court?s) writes:
> The request sense KCQ can be interpreted as ?Not Ready - Medium Not
> Present?, according to
> <https://secure.wikimedia.org/wikipedia/en/wiki/KCQ>, despite the fact
> that the SD card is actually in (and Linux can successfully read from
> it.)
>
> The card reader has USB IDs 05e3:0726 (Genesys Logic).
The problem was that this card reader exposes two SCSI logical units
(LUNs), whereas the code in ?usb_storage.c? assumed single-LUN devices
(which is typically the case with USB keys and disks.)
The patch below adds support for multiple-LUN devices like this one.
Tested on the GuruPlug.
The net effect for the GuruPlug is that it makes it possible to boot a
kernel stored on a microSD card, something long overdue [0, 1].
Can you please review and apply?
Thanks,
Ludo?.
[0] http://plugcomputer.org/plugforum/index.php?topic=1642
[1] It really feels like I?m doing GlobalScale?s or Marvell?s job here.
It looks like GlobalScale is steadily strengthening its reputation
of being incompetent. Keep up the bad work!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-usb-Add-support-for-multiple-LUN-mass-storage-device.patch
Type: text/x-patch
Size: 4166 bytes
Desc: the patch
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101005/96e83f44/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101005/96e83f44/attachment.pgp
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] usb: Add support for multiple-LUN mass storage devices
[not found] ` <26012718.1256010.1286282818170.JavaMail.root@zmbs1.inria.fr>
@ 2010-10-05 19:28 ` Ludovic Courtès
0 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2010-10-05 19:28 UTC (permalink / raw)
To: u-boot
Hi Prafulla,
Prafulla Wadaskar <prafulla@marvell.com> writes:
> This works for guruplug, I can detect filesystems on both the uSD card on guruplug
Great, thanks for testing.
> The patch could not be applied cleanly on latest u-boot, pls redo it
> and post it to mailing list (Not as attachment)
I posted an updated patch, which applies cleanly on top of commit
d6288664743cdd4824cb877ca424619c827c1256 (Tue Oct 5 14:42:32 2010 +0200)
of ?master? in the u-boot.git repo.
> Please follow patch submission process http://www.denx.de/wiki/U-Boot/Patches
Let me know if there other specific changes that should be made.
Thanks for reviewing,
Ludo?.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101005/aa6e2ef0/attachment.pgp
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH v2] usb: Add support for multiple-LUN mass storage devices
2010-10-04 22:11 ` [U-Boot] [PATCH] usb: Add support for multiple-LUN mass storage devices Ludovic Courtès
[not found] ` <26012718.1256010.1286282818170.JavaMail.root@zmbs1.inria.fr>
@ 2010-10-05 20:04 ` Ludovic Courtès
2010-10-13 14:18 ` [U-Boot] [PATCH v2, PING] " Ludovic Courtès
1 sibling, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2010-10-05 20:04 UTC (permalink / raw)
To: u-boot
This patch changes `usb_stor_scan' to scan all the LUNs of each mass
storage device. It also fixes the various commands to correctly set
the LUN field.
Notably, it allows each LUN of GuruPlug's microSD card reader to be
accessed.
Signed-off-by: Ludovic Court?s <ludo@gnu.org>
Acked-by: Prafulla Wadaskar <prafulla@marvell.com>
---
Changes for v2:
- commit log changed to more closely follow the patch submission
rules
common/usb_storage.c | 39 +++++++++++++++++++++++++++++++++++----
1 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 76949b8..613c4f0 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -204,6 +204,22 @@ int usb_stor_info(void)
return 1;
}
+static unsigned int usb_get_max_lun(struct us_data *us)
+{
+ int len;
+ unsigned char result;
+ len = usb_control_msg(us->pusb_dev,
+ usb_rcvctrlpipe(us->pusb_dev, 0),
+ US_BBB_GET_MAX_LUN,
+ USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
+ 0, us->ifnum,
+ &result, sizeof(result),
+ USB_CNTL_TIMEOUT * 5);
+ USB_STOR_PRINTF("Get Max LUN -> len = %i, result = %i\n",
+ len, (int) result);
+ return (len > 0) ? result : 0;
+}
+
/*******************************************************************************
* scan the usb and reports device info
* to the user if mode = 1
@@ -241,13 +257,22 @@ int usb_stor_scan(int mode)
break; /* no more devices avaiable */
if (usb_storage_probe(dev, 0, &usb_stor[usb_max_devs])) {
- /* ok, it is a storage devices
- * get info and fill it in
+ /* OK, it's a storage device. Iterate over its LUNs
+ * and populate `usb_dev_desc'.
*/
- if (usb_stor_get_info(dev, &usb_stor[usb_max_devs],
- &usb_dev_desc[usb_max_devs]) == 1)
+ int lun, max_lun, start = usb_max_devs;
+
+ max_lun = usb_get_max_lun(&usb_stor[usb_max_devs]);
+ for (lun = 0;
+ lun <= max_lun && usb_max_devs < USB_MAX_STOR_DEV;
+ lun++) {
+ usb_dev_desc[usb_max_devs].lun = lun;
+ if (usb_stor_get_info(dev, &usb_stor[start],
+ &usb_dev_desc[usb_max_devs]) == 1) {
usb_max_devs++;
}
+ }
+ }
/* if storage device */
if (usb_max_devs == USB_MAX_STOR_DEV) {
printf("max USB Storage Device reached: %d stopping\n",
@@ -882,6 +907,7 @@ static int usb_inquiry(ccb *srb, struct us_data *ss)
do {
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_INQUIRY;
+ srb->cmd[1] = srb->lun << 5;
srb->cmd[4] = 36;
srb->datalen = 36;
srb->cmdlen = 12;
@@ -905,6 +931,7 @@ static int usb_request_sense(ccb *srb, struct us_data *ss)
ptr = (char *)srb->pdata;
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_REQ_SENSE;
+ srb->cmd[1] = srb->lun << 5;
srb->cmd[4] = 18;
srb->datalen = 18;
srb->pdata = &srb->sense_buf[0];
@@ -924,6 +951,7 @@ static int usb_test_unit_ready(ccb *srb, struct us_data *ss)
do {
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_TST_U_RDY;
+ srb->cmd[1] = srb->lun << 5;
srb->datalen = 0;
srb->cmdlen = 12;
if (ss->transport(srb, ss) == USB_STOR_TRANSPORT_GOOD)
@@ -943,6 +971,7 @@ static int usb_read_capacity(ccb *srb, struct us_data *ss)
do {
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_RD_CAPAC;
+ srb->cmd[1] = srb->lun << 5;
srb->datalen = 8;
srb->cmdlen = 12;
if (ss->transport(srb, ss) == USB_STOR_TRANSPORT_GOOD)
@@ -957,6 +986,7 @@ static int usb_read_10(ccb *srb, struct us_data *ss, unsigned long start,
{
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_READ10;
+ srb->cmd[1] = srb->lun << 5;
srb->cmd[2] = ((unsigned char) (start >> 24)) & 0xff;
srb->cmd[3] = ((unsigned char) (start >> 16)) & 0xff;
srb->cmd[4] = ((unsigned char) (start >> 8)) & 0xff;
@@ -973,6 +1003,7 @@ static int usb_write_10(ccb *srb, struct us_data *ss, unsigned long start,
{
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_WRITE10;
+ srb->cmd[1] = srb->lun << 5;
srb->cmd[2] = ((unsigned char) (start >> 24)) & 0xff;
srb->cmd[3] = ((unsigned char) (start >> 16)) & 0xff;
srb->cmd[4] = ((unsigned char) (start >> 8)) & 0xff;
--
1.7.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH v2, PING] usb: Add support for multiple-LUN mass storage devices
2010-10-05 20:04 ` [U-Boot] [PATCH v2] " Ludovic Courtès
@ 2010-10-13 14:18 ` Ludovic Courtès
2010-10-13 16:02 ` Remy Bohmer
0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2010-10-13 14:18 UTC (permalink / raw)
To: u-boot
This patch changes `usb_stor_scan' to scan all the LUNs of each mass
storage device. It also fixes the various commands to correctly set
the LUN field.
Notably, it allows each LUN of GuruPlug's microSD card reader to be
accessed.
Signed-off-by: Ludovic Court?s <ludo@gnu.org>
Acked-by: Prafulla Wadaskar <prafulla@marvell.com>
---
Changes for v2:
- commit log changed to more closely follow the patch submission
rules
common/usb_storage.c | 39 +++++++++++++++++++++++++++++++++++----
1 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 76949b8..613c4f0 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -204,6 +204,22 @@ int usb_stor_info(void)
return 1;
}
+static unsigned int usb_get_max_lun(struct us_data *us)
+{
+ int len;
+ unsigned char result;
+ len = usb_control_msg(us->pusb_dev,
+ usb_rcvctrlpipe(us->pusb_dev, 0),
+ US_BBB_GET_MAX_LUN,
+ USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
+ 0, us->ifnum,
+ &result, sizeof(result),
+ USB_CNTL_TIMEOUT * 5);
+ USB_STOR_PRINTF("Get Max LUN -> len = %i, result = %i\n",
+ len, (int) result);
+ return (len > 0) ? result : 0;
+}
+
/*******************************************************************************
* scan the usb and reports device info
* to the user if mode = 1
@@ -241,13 +257,22 @@ int usb_stor_scan(int mode)
break; /* no more devices avaiable */
if (usb_storage_probe(dev, 0, &usb_stor[usb_max_devs])) {
- /* ok, it is a storage devices
- * get info and fill it in
+ /* OK, it's a storage device. Iterate over its LUNs
+ * and populate `usb_dev_desc'.
*/
- if (usb_stor_get_info(dev, &usb_stor[usb_max_devs],
- &usb_dev_desc[usb_max_devs]) == 1)
+ int lun, max_lun, start = usb_max_devs;
+
+ max_lun = usb_get_max_lun(&usb_stor[usb_max_devs]);
+ for (lun = 0;
+ lun <= max_lun && usb_max_devs < USB_MAX_STOR_DEV;
+ lun++) {
+ usb_dev_desc[usb_max_devs].lun = lun;
+ if (usb_stor_get_info(dev, &usb_stor[start],
+ &usb_dev_desc[usb_max_devs]) == 1) {
usb_max_devs++;
}
+ }
+ }
/* if storage device */
if (usb_max_devs == USB_MAX_STOR_DEV) {
printf("max USB Storage Device reached: %d stopping\n",
@@ -882,6 +907,7 @@ static int usb_inquiry(ccb *srb, struct us_data *ss)
do {
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_INQUIRY;
+ srb->cmd[1] = srb->lun << 5;
srb->cmd[4] = 36;
srb->datalen = 36;
srb->cmdlen = 12;
@@ -905,6 +931,7 @@ static int usb_request_sense(ccb *srb, struct us_data *ss)
ptr = (char *)srb->pdata;
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_REQ_SENSE;
+ srb->cmd[1] = srb->lun << 5;
srb->cmd[4] = 18;
srb->datalen = 18;
srb->pdata = &srb->sense_buf[0];
@@ -924,6 +951,7 @@ static int usb_test_unit_ready(ccb *srb, struct us_data *ss)
do {
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_TST_U_RDY;
+ srb->cmd[1] = srb->lun << 5;
srb->datalen = 0;
srb->cmdlen = 12;
if (ss->transport(srb, ss) == USB_STOR_TRANSPORT_GOOD)
@@ -943,6 +971,7 @@ static int usb_read_capacity(ccb *srb, struct us_data *ss)
do {
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_RD_CAPAC;
+ srb->cmd[1] = srb->lun << 5;
srb->datalen = 8;
srb->cmdlen = 12;
if (ss->transport(srb, ss) == USB_STOR_TRANSPORT_GOOD)
@@ -957,6 +986,7 @@ static int usb_read_10(ccb *srb, struct us_data *ss, unsigned long start,
{
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_READ10;
+ srb->cmd[1] = srb->lun << 5;
srb->cmd[2] = ((unsigned char) (start >> 24)) & 0xff;
srb->cmd[3] = ((unsigned char) (start >> 16)) & 0xff;
srb->cmd[4] = ((unsigned char) (start >> 8)) & 0xff;
@@ -973,6 +1003,7 @@ static int usb_write_10(ccb *srb, struct us_data *ss, unsigned long start,
{
memset(&srb->cmd[0], 0, 12);
srb->cmd[0] = SCSI_WRITE10;
+ srb->cmd[1] = srb->lun << 5;
srb->cmd[2] = ((unsigned char) (start >> 24)) & 0xff;
srb->cmd[3] = ((unsigned char) (start >> 16)) & 0xff;
srb->cmd[4] = ((unsigned char) (start >> 8)) & 0xff;
--
1.7.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH v2, PING] usb: Add support for multiple-LUN mass storage devices
2010-10-13 14:18 ` [U-Boot] [PATCH v2, PING] " Ludovic Courtès
@ 2010-10-13 16:02 ` Remy Bohmer
0 siblings, 0 replies; 8+ messages in thread
From: Remy Bohmer @ 2010-10-13 16:02 UTC (permalink / raw)
To: u-boot
Hi,
2010/10/13 Ludovic Court?s <ludo@gnu.org>:
> This patch changes `usb_stor_scan' to scan all the LUNs of each mass
> storage device. ?It also fixes the various commands to correctly set
> the LUN field.
>
> Notably, it allows each LUN of GuruPlug's microSD card reader to be
> accessed.
>
> Signed-off-by: Ludovic Court?s <ludo@gnu.org>
> Acked-by: Prafulla Wadaskar <prafulla@marvell.com>
> ---
> Changes for v2:
> ?- commit log changed to more closely follow the patch submission
> ? ?rules
>
>
> ?common/usb_storage.c | ? 39 +++++++++++++++++++++++++++++++++++----
> ?1 files changed, 35 insertions(+), 4 deletions(-)
>
This patch was already applied to u-boot-usb a few days ago.
Thanks.
Kind regards,
Remy
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-10-13 16:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-01 16:17 [U-Boot] SD card on the GuruPlug Ludovic Courtès
2010-10-02 23:12 ` [U-Boot] Troubles accessing a USB mass storage device Ludovic Courtès
2010-10-04 22:11 ` [U-Boot] [PATCH] usb: Add support for multiple-LUN mass storage devices Ludovic Courtès
[not found] ` <26012718.1256010.1286282818170.JavaMail.root@zmbs1.inria.fr>
2010-10-05 19:28 ` Ludovic Courtès
2010-10-05 20:04 ` [U-Boot] [PATCH v2] " Ludovic Courtès
2010-10-13 14:18 ` [U-Boot] [PATCH v2, PING] " Ludovic Courtès
2010-10-13 16:02 ` Remy Bohmer
[not found] ` <1235049614.358782.1286186899690.JavaMail.root@zmbs1.inria.fr>
2010-10-04 14:26 ` [U-Boot] SD card on the GuruPlug Ludovic Courtès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox