public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot]  USB mass storage gadget patch
@ 2012-11-02 11:07 victor
  2012-11-02 13:19 ` Lukasz Majewski
  0 siblings, 1 reply; 10+ messages in thread
From: victor @ 2012-11-02 11:07 UTC (permalink / raw)
  To: u-boot

Lukasz,

I am looking at the usb mass storage gadget patch from you at:
http://patchwork.ozlabs.org/patch/104516/

I am trying to use this patch in the u-boot. Some questions:
1) Is this patch in U-boot git release?
2) Now I can use the patch and process till SCSI MODE_SELECT_6 command, and
then problem is encountered. Basically the SCSI MODE_SELECT_6 is sent to EP1
Out, then data is sent to EP1 out, and the fsg_main_thread only sees the
data. I change the code to force the CSW.

The changes are:
1) fix the buf pointer in scsi inquiry
2) fix the buf pointer in scsi read format capacities
3) fix the buf pointer in CSW sending
4) fix attention condition checking in scsi command check
5) fix the context pointer before queue a request to read bulk only CBW
6) change bulk out endpoint from endpoint 2 to endpoint 1 to accommodate
gen2 usb hardware limitation
7) in pad_with_zeros(), comment out the bh->inreq->length = nsend
8) in received_cbw(), force to send CSW if CBW is invalid. Otherwise, the
IRQ routine keeps on reading the same data.

I attach the file for your reference. Please kindly advise me. Thanks.

Thanks,
victor

================================================================================================
CONFIDENTIALITY NOTE:
This e-mail and any attachments may contain confidential information and may be protected by legal privilege. If you are not the intended addressee (or authorized to receive for the addressee). be aware that any disclosure, copying, distribution or use of this e-mail or any attachment is prohibited. If you have received this e-mail in error, please notify us immediately by returning it to the sender and delete this copy from your system. Thank you for your cooperation.
KeyASIC Inc.
================================================================================================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file_storage.c
Type: application/octet-stream
Size: 106931 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121102/f6d8c100/attachment.obj>

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [U-Boot] USB mass storage gadget patch
@ 2012-11-02 11:43 victor
  0 siblings, 0 replies; 10+ messages in thread
From: victor @ 2012-11-02 11:43 UTC (permalink / raw)
  To: u-boot

>> I attach the file for your reference. Please kindly advise me. Thanks.

The changes of file_storage.c:

--- file_storage.c	2012-11-02 18:27:41.072702402 +0800
+++ file_storage.orig.c	2012-11-02 19:36:37.992528292 +0800

@@ -746,10 +745,6 @@
 	struct fsg_dev		*fsg = ep->driver_data;
 	struct fsg_buffhd	*bh = req->context;
 
-ga_bh = bh;
-ga_tag = fsg->tag;
-
 	dump_msg(fsg, "bulk-out", req->buf, req->actual);
 	if (req->status || req->actual != bh->bulk_out_intended_length)
 		DBG(fsg, "%s --> %d, %u/%u\n", __func__,

@@ -1185,9 +1174,6 @@
 				return rc;
 		}
 
-bh->inreq->buf = bh->buf;
-
 		/* If we were asked to read past the end of file,
 		 * end with an empty buffer. */
 		if (amount == 0) {
@@ -1575,8 +1560,6 @@
 	static char vendor_id[] = "Linux   ";
 	static char product_cdrom_id[] = "File-CD Gadget  ";
 
-bh->inreq->buf = bh->buf;	
 
 	if (!fsg->curlun) {		// Unsupported LUNs are okay
 		fsg->bad_lun_okay = 1;
@@ -1667,15 +1649,12 @@
 	int		pmi = fsg->cmnd[8];
 	u8		*buf = (u8 *) bh->buf;
 
-bh->inreq->buf = bh->buf;
 	/* Check the PMI and LBA fields */
 	if (pmi > 1 || (pmi == 0 && lba != 0)) {
 		curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
 		return -EINVAL;
 	}
 
@@ -1755,8 +1734,6 @@
 		curlun->sense_data = SS_SAVING_PARAMETERS_NOT_SUPPORTED;
 		return -EINVAL;
 	}
-printf("C %s %x ", __func__, (u8 *)bh->buf);
-bh->inreq->buf = bh->buf;
 
 	changeable_values = (pc == 1);
 	all_pages = (page_code == 0x3f);
@@ -1865,8 +1842,6 @@
 	struct fsg_lun	*curlun = fsg->curlun;
 	u8		*buf = (u8 *) bh->buf;
 
-printf("%s\n",__func__);
-bh->inreq->buf = bh->buf;
 	buf[0] = buf[1] = buf[2] = 0;
 	buf[3] = 8;		// Only the Current/Maximum Capacity
Descriptor
 	buf += 4;
@@ -1956,9 +1931,8 @@
 
 		nsend = min(fsg->usb_amount_left, (u32) mod_data.buflen);
 		memset(bh->buf + nkeep, 0, nsend - nkeep);
-		//bh->inreq->length = nsend;
+		bh->inreq->length = nsend;
 		bh->inreq->zero = 0;
-printf("%s %x %d %d\n", __func__, (u8 *)bh, bh->inreq->length, nsend);
 		start_transfer(fsg, fsg->bulk_in, bh->inreq,
 				&bh->inreq_busy, &bh->state);
 		bh = fsg->next_buffhd_to_fill = bh->next;

@@ -2137,13 +2107,7 @@
 
 	/* Wait for the next buffer to become available */
 	bh = fsg->next_buffhd_to_fill;
-printf("%s %x %d\n", __func__,  (u8 *)bh, bh->state);
 	while (bh->state != BUF_STATE_EMPTY) {
-if (bh->state == BUF_STATE_FULL)
-{
-	bh->state = BUF_STATE_EMPTY;
-	break;
-}
 		rc = sleep_thread(fsg, __LINE__);
 		if (rc)
 			return rc;
@@ -2180,8 +2144,6 @@
 
 		bh->inreq->length = USB_BULK_CS_WRAP_LEN;
 		bh->inreq->zero = 0;
-bh->inreq->buf = bh->buf;
-printf("bbb %s %x %d\n", __func__, (u8 *)bh, bh->state);
 		start_transfer(fsg, fsg->bulk_in, bh->inreq,
 				&bh->inreq_busy, &bh->state);
 

@@ -2362,12 +2320,9 @@
 	for (i = 1; i < cmnd_size; ++i) {
 		if (fsg->cmnd[i] && !(mask & (1 << i))) {
 
			if (curlun)
 				curlun->sense_data =
SS_INVALID_FIELD_IN_CDB;
			//return -EINVAL;

 		}
 	}
			
@@ -2669,8 +2620,6 @@
 
                 ga_bh->inreq->length = USB_BULK_CS_WRAP_LEN;
                 ga_bh->inreq->zero = 0;
-ga_bh->inreq->buf = ga_bh->buf;
-printf("bbb %s %x %d\n", __func__, (u8 *)ga_bh, ga_bh->state);
                 start_transfer(fsg, fsg->bulk_in, ga_bh->inreq,
                                 &(ga_bh->inreq_busy), &(ga_bh->state));
 
@@ -2732,26 +2679,20 @@
 		/* Queue a request to read a Bulk-only CBW */
 		set_bulk_out_req_length(fsg, bh, USB_BULK_CB_WRAP_LEN);
 		bh->outreq->short_not_ok = 1;
-printf("call start_transfer, %x %x\n", (u8 *)bh, (u8 *)(fsg->bulk_out));
-bh->outreq->context = bh;
 		start_transfer(fsg, fsg->bulk_out, bh->outreq,
 				&bh->outreq_busy, &bh->state);
 		
@@ -3468,8 +3406,6 @@
 	ep->driver_data = fsg;		// claim the endpoint
 	fsg->bulk_out = ep;
 
-if (fsg_fs_bulk_out_desc.bEndpointAddress != 0x1)
-	fsg_fs_bulk_out_desc.bEndpointAddress = 0x1;
 
 	if (transport_is_cbi()) {
 		ep = usb_ep_autoconfig(gadget, &fsg_fs_intr_in_desc);


================================================================================================
CONFIDENTIALITY NOTE:
This e-mail and any attachments may contain confidential information and may be protected by legal privilege. If you are not the intended addressee (or authorized to receive for the addressee). be aware that any disclosure, copying, distribution or use of this e-mail or any attachment is prohibited. If you have received this e-mail in error, please notify us immediately by returning it to the sender and delete this copy from your system. Thank you for your cooperation.
KeyASIC Inc.
================================================================================================

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-11-22  2:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-02 11:07 [U-Boot] USB mass storage gadget patch victor
2012-11-02 13:19 ` Lukasz Majewski
2012-11-05  2:30   ` victor
2012-11-05  6:45   ` victor
2012-11-06  6:46   ` victor
2012-11-06  9:03     ` Lukasz Majewski
2012-11-06  9:58       ` victor
2012-11-06 11:08       ` victor
2012-11-22  2:24       ` victor
  -- strict thread matches above, loose matches on Subject: below --
2012-11-02 11:43 victor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox