-
1. Re: Control IN transfer fails when the response size is multiple of packet size.
nikhiln_ Jul 22, 2013 3:58 AM (in response to TaKu_282151)Are you trying to read (from pc side) less than what is committed by the firmware? If yes, the psec does not allow that. You can read more than what is committed by firmware but not less. -
2. Re: Control IN transfer fails when the response size is multiple of packet size.
TaKu_282151 Jul 22, 2013 4:50 AM (in response to TaKu_282151)>Are you trying to read (from pc side) less than what is committed by the firmware?
No.
In PC side, I simply call ControlTransfer Read API (ex.CyUSB.CyControlEndPoint.Read).
But the firmware is trying to send less than what is required from the PC.
I understand that the USB device can send fewer size data than wLength
in Control-IN transaction.
In this situation, if the transmitting size is multiple of packet size,
the transfer is not completed.
Regards.
-
3. Re: Control IN transfer fails when the response size is multiple of packet size.
TaKu_282151 Jul 22, 2013 10:08 PM (in response to TaKu_282151)Let me apologize I had misunderstanding that CyU3PUsbSendEP0Data() API should be called only once
in each control-transfer transaction.
But this API can be called two or more times, and the programmer shall create the last ZLP explicitly.
Regards.
-
4. Re: Control IN transfer fails when the response size is multiple of packet size.
gayathriv_16 Jul 24, 2013 3:01 AM (in response to TaKu_282151)Hi,
Is the issue fixed? I did not understand the issue clearly. What do you mean by terms response size? I understand packet size and wLength. Also, since it is control transfer, when you say packet size, it is 64 byte (max) for EP0 in case of HS; and 512 bytes (max) for EP0 in case of SS. Please clarify as to what is teh MaxPacketsize used for EP0 and what you mean by reposne size?
Regards,
Gayathri
-
5. Re: Control IN transfer fails when the response size is multiple of packet size.
TaKu_282151 Jul 24, 2013 7:31 AM (in response to TaKu_282151)Hi,
I use the term "packet size" as "MaxPacketSize used for EP0", like you say.
But "response size" does not means "wLength".
I use this term as "total bytes of the data that USB device will send in the data phase".
(Of cause, the maximum size is limited by wLength)
When this "response size" is smaller than wLength, the last packet of sending data must be SLP or ZLP.
But FX3 API Guide says in senction 6.3.3.19 CyU3PUsbSendEP0Data:
Multiple calls of this function can be made to respond to a single control request as long as each call sends an integral number of full packets to the host.
I understand this sentence means "CyU3PUsbSendEP0Data API does not append the last ZLP for termination".
Is this right?
Regards.
-
6. Re: Control IN transfer fails when the response size is multiple of packet size.
gayathriv_16 Jul 25, 2013 4:39 AM (in response to TaKu_282151)Hi,
Yes that is what it means.
Regards,
Gayathri
-
7. Re: Control IN transfer fails when the response size is multiple of packet size.
gayathriv_16 Jul 25, 2013 4:46 AM (in response to TaKu_282151)Hi,
If your actual data that devcie has to send is less < wLength, and the actual data is it is a multiple of maxPacketSize, then a ZLP should be explicitly sent using SendEpoData API.
Regards,
Gayathri
-
8. Re: Control IN transfer fails when the response size is multiple of packet size.
content.librarian Aug 13, 2013 7:23 AM (in response to TaKu_282151)Hi, is this workaround also relevant in the bootloader API of cypress? Thanks, lumpi -
9. Re: Control IN transfer fails when the response size is multiple of packet size.
content.librarian Aug 19, 2013 9:16 AM (in response to TaKu_282151)Hi, does anybody know how it is with the IN transfer in case of bootloader SDK of FX3? Thanks, lumpi -
10. Re: Control IN transfer fails when the response size is multiple of packet size.
userc_39074 Aug 22, 2013 4:25 AM (in response to TaKu_282151)Yes Lumpi.
Regards,
sai krishna.
-
11. Re: Control IN transfer fails when the response size is multiple of packet size.
content.librarian Aug 22, 2013 5:17 AM (in response to TaKu_282151)Hi Sai Krishna,
are there any code snippets or example code of bootloader how to implement the ZLP?
I believe just adding an additional call of
if (eDataIn == u32Stage)
{
if ((u32Address + pEp0->wLen) < CY_FX3_BOOT_ITCM_END)
{
myMemCopy(pEp0->pData, (IS_U8 *)u32Address , u16Len);
}
CyFx3BootUsbAckSetup ();
nRet = CyFx3BootUsbDmaXferData (0x80, (IS_U32)pEp0->pData, pEp0->wLen, USB_DMA_XFER_TIMEOUT_EP0_IN);
if (nRet != CY_U3P_SUCCESS)
{
/* USB DMA Transfer failed. Stall the Endpoint. */
return nRet;
}
if ((pEp0->wLen % g_u32UsbPktSize) == 0)
{
nRet = CyFx3BootUsbDmaXferData (0x80, (IS_U32)pEp0->pData, 0, USB_DMA_XFER_TIMEOUT_EP0_IN);
if (nRet != CY_U3P_SUCCESS)
{
/* USB DMA Transfer failed. Stall the Endpoint. */
return nRet;
}
}
}
regards,
lumpi
-
12. Re: Control IN transfer fails when the response size is multiple of packet size.
content.librarian Sep 19, 2013 1:50 AM (in response to TaKu_282151)Hi,
is the ZLP functionality in bootloader working fine when I implement it as I described in previous post?
is there an example how to add the ZLP functionality in new bootloader firmware release? Can I get it?
regards,
lumpi
-
13. Re: Control IN transfer fails when the response size is multiple of packet size.
content.librarian Sep 19, 2013 1:50 AM (in response to TaKu_282151)Hi,
is the ZLP functionality in bootloader working fine when I implement it as I described in previous post?
is there an example how to add the ZLP functionality in new bootloader firmware release? Can I get it?
regards,
lumpi
-
14. Re: Control IN transfer fails when the response size is multiple of packet size.
kasi_283151 Sep 20, 2013 5:39 AM (in response to TaKu_282151)Hi Lumpi,
The issue described in first post is relevant to CyU3PUsbSendEP0Data(). I am not sure that it's characteristic also to bootloader's CyFx3BootUsbDmaXferData function. You should test this first. I remember playing with bootloader about a year ago and then its functions behaved different from application ones - at least I was not able to get single control transfer working with splitting it into multiple calls of CyFx3BootUsbDmaXferData.
Anyway, terminating ZLP is needed only if you return less data from device than the host requested. In your example you do not check this. It's very common for host applications to initiate transfers that are multiple to packet size. And these transfers work with Cypress bootloader. With your modification, you will send extra ZLP that is not needed/expected.
But why should you return less data than host requests? I see, this can happen only while returning descriptors. And even then only if host tries to get the whole descriptor without asking/checking its length first. Hopefully the descriptors are not multiple to packet size. In vendor requests, when host asks for too much data, you can just fail the request, like the original Cypress bootloader does.
BTW, Cypress has promised to release FX3 API sources in next SDK release. Then it will be easy to study what the functions actually do and change/fix them according your needs.
Br,
Kalev