LPC4330 USB device response to IN bulk endpoint

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC4330 USB device response to IN bulk endpoint

1,344 Views
venkatvallapane
Contributor II

Hi,

I have set USB1 as device with IN and OUT bulk endpoints.

When PC requests URB_BULK in packet with URB length as 0x583e0, my response is only 0xf000 (I respond using WriteEP method).

When I look at my response packet, I see that URB length is 0xf000 and data length is 0xf000.

I expect URB length to be 0x583e0 and data length as 0xf000.

Please let me know why URB length is changed to actual length from the requested length.

Looks like my app (which is a pre-compiled library from 3rd party) expects URB length as requested length in response.

On side-note, I noticed that if number of bytes to write is 0x8000 to WriteEP function, it is sending null packet!

so my response of 0xf000, I split to three packets: First I caled WriteEP with 0x7FC0 as number of bytes to write and in my EP handler, I called WriteEP with 0x7040 and then WriteEP with 0x0 (null packet to terminate).

// My EP handler function...

// First WriteEP with 0x7FC0 happens somewhere else in the core before URB_BULK in packet

    static uint8_t pkt_cnt = 0;
    if(pkt_cnt == 0) {
        USBD_API->hw->WriteEP(hUsb, 0x82, g_data+0x7FC0,0x7040);
        pkt_cnt++;
    } else if(pkt_cnt == 1) {
        USBD_API->hw->WriteEP(hUsb, 0x82, g_data,0x0);
        pkt_cnt++;
    } else {
        pkt_cnt = 0;
    }
    return LPC_OK;

Rgds,

Venkat.

Labels (3)
0 Kudos
7 Replies

967 Views
venkatvallapane
Contributor II

Hi,

I am struck with this issue. Please let me know your inputs.

Rgds,

Venkat.

0 Kudos

967 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Venkat Vallapaneni,

Thank you for your interest in NXP Semiconductor products and 
the opportunity to serve you.
I'd like to know what demo and board you use and I was wondering if you can share your testing demo and app, then I can replicate the issue on my site.
I'm looking forward to your reply.
Have a great day,

TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

967 Views
venkatvallapane
Contributor II

Hi,

I am using NGX LPC4330 Xplorer board.

I am attaching my LPC4330 project, sample PC application c code using libusb-1.0 and wireshark USB trace.

LPC project: usb_test

C code for PC: usbd/usbtr.c

USB trace from wireshark: usb_traces/usb_test.pcapng

If you see wireshark trace, you would notice that URB length from host to device for URB_BULK IN is 361440 (0x583E0). But response packet from device to host is having URB length as 61440 (0xf000).

Please note that my data length in response is also 0xf000.

But what I want in response packet is: URB length matching request packet (which is 0x583E0) and data length is 0xf000 (as I respond with these many bytes).

Please let me know if you need further information regarding this.

Rgds,

Venkat.

0 Kudos

967 Views
venkatvallapane
Contributor II

jeremyzhou‌,

Any update for me on this? I am struck in my project because of this issue.

Any update on this is highly appreciated.

Also, is it possible to have a local NXP contact (I am in Bangalore, India) for supporting this issue?

Rgds,

Venkat.

0 Kudos

967 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Venkat Vallapaneni,

I had already escalated the question, and USB expert will reply later.

Thanks for patient.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

967 Views
venkatvallapane
Contributor II

Hi jeremyzhou,

Any update on this?

For now, I got an work around for this problem.

But I have one question to implement the work around:

Is there any callback when BULK IN transfer is received by the device?

I see that endpoint handler is called only after BULK IN is completed.

I would like to know when it is initiated by PC (USB host) and with what size?

Rgds,

Venkat.

0 Kudos

967 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Venkat Vallapaneni,

I hasn't received any updates until now, and I'd like to escalate your question, so I was wondering if you can describe your question in details again.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos