This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USB endpoint transfer pipe error

Hi,

I'm trying to evaluate the performance of USB and using USB MSC example to do bulk transfers in between host (PC) device (nRF52840)

I'm using libusb on PC side and sending 64 bytes of data in a loop using bulk transfer. On device side I'm using 'app_usbd_ep_transfer' function in a loop on NRF_DRV_USBD_EPOUT1  endpoint of the interface.

I see the first 64 bytes of transfer is received successfully but after that I get pipe error on libusb side and can't continue to bulk transfers. How can I call this function in a loop? Should I call another function to wait/clear some flags until/after the transfer is completed? Is there a usb device example code which would help with handling the endpoint data transfers in a loop?

Thanks and Best Regards,

Asli

Parents
  • Hi,

    Looking at the documenation here, libusb_bulk_transfer () returning LIBUSB_ERROR_PIPE , means that the endpoint is halted. I think you might need to call libusb_clear_halt, and then try again. Take a look at this code here.

    We dont't have any libusb CDC MSC driver examples, but we have a libusb USB CDC ACM driver for javascript found here.

  • Hi Sigurd,

    I'm calling libusb_clear_halt() after each bulk transfer on libusb side when there's LIBUSB_PIPE_ERROR already. On Nordic side the program is stopping at line#100 (NRF_BREAKPOINT_COND) of app_error_weak.c file  with '[00:00:00.046,417] <error> app: ASSERTION FAILED at ..\usbd\class\msc\app_usbd_msc.c:2093' . ( ASSERT(0);
    ret = NRF_ERROR_NOT_SUPPORTED;)

    I think I'm doing something wrong on the Nordic side. Is any of the usb examples showing how to handle the incoming data from host to device in a loop or something similar I can use? 

    Thanks,

    Asli

  • 1) Have you made any changes to the usbd_msc example ?

    2) Are you using a nRF52840-DK version 1.0.0 ?

    3) Are you using SDK 15.2 ?

    Could you try to set APP_USBD_MSC_CONFIG_LOG_ENABLED to 1 and APP_USBD_MSC_CONFIG_LOG_LEVEL to 4 in sdk_config.h , and see what the log output is ?

    The endpoint_out_event_handler() should then print the internal module state.

    If you want RTT logging, set NRF_LOG_BACKEND_RTT_ENABLED to 1. You might also want to set NRF_LOG_DEFAULT_LEVEL to 4.

  • 1) I just added below buffer as global to the msc main.c file

    static uint8_t data_from_host[64];

    NRF_DRV_USBD_TRANSFER_OUT(epOutTransfer, data_from_host, 64);

    and I'm calling in the while loop, in main function

    ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT1, &epOutTransfer);

    2) I have a Rigado BMD-340 evaluation board.

    3) Yes

    I enabled the logging as recommended. I get below: 

    [00:00:00.000,000] <info> app: Mounting volume...
    [00:00:00.000,000] <error> app: Mount failed. Filesystem not found. Please format device.
    [00:00:00.000,000] <info> app: USBD MSC example started.
    [00:00:00.000,000] <info> app: USB power detected
    [00:00:00.000,000] <info> app: Un-initializing disk 0 (QSPI)...
    [00:00:00.000,000] <info> app: USB ready

    [00:00:00.021,118] <debug> usbd_msc: state: 0, ep out event, status: 0
    [00:00:00.021,118] <error> app: ASSERTION FAILED at ..\components\libraries\usbd\class\msc\app_usbd_msc.c:2093

    Thanks,

    Asli

  • Hi,

    ASLI said:
    1) I just added below buffer as global to the msc main.c file

     Could you upload the main.c you are using?

    ASLI said:
    [00:00:00.000,000] <error> app: Mount failed. Filesystem not found. Please format device.

     Are you able to get the filesystem to mount on the  BMD-340 with the unmodified example?

    Are you using the QSPI/ external flash on the BMD-340?

  • Hi Sigurd,

    I actually moved away from using the usbd_msc example. I modified usbd example and now I can transfer data in between host and device. But I have issues with usb speed now and I need more help to debug this issue.

    I'll describe the problem here but if I need to create a new ticket for this problem, I will.

    The host side is using libusb-1.0, sending 16 X 64  = 1K bytes bulk data from ENDPOINTOUT1  using libusb_bulk_transfer function and after the device receiving 1 KByte data it's sending back the data to the host on ENDPOINTIN1. Data is transferred correctly but the time spent to do just 1 KByte transfer is very long and varying a lot. I measured varying rates from 2 - 100 KBytes/second. I tried various libusb drivers (winUSB, libusb-win32 and libusbK) to see any variation with data rate but didn't see any difference.

    I'm  attaching the main.c for convenience.

    I'm measuring the time spent to send and receive data on the usb device toggling LED's and measuring those using a logic analyzer.  

    Using LED_SEND to measure time spent on ENDPOINTIN1 and using LED_RECEIVE to measure time on ENDPOINTOUT1. 

    My understanding from the nRF52840_PS_v1.0.pdf,  usb has to run with the high frequency clock (which is 64 MHz ?) However even I don't start hfclk in clock_init function (I comment out all clock start and request functions, from line#1030 to line#1040) I don't see any differences with the speed. It varies but it is very slow compared to expected bulk transfer rates.  At this point I don't know how to debug this speed issue further. I'm attaching two captures showing the SEND and RECEIVE times with and without hflck enabled. Can you please help with this?

    Thank you and Best Regards,

    Asli

    USB device receive and send time, hfclk disabled

    USB device receive and send time, hfclk enabled

Reply
  • Hi Sigurd,

    I actually moved away from using the usbd_msc example. I modified usbd example and now I can transfer data in between host and device. But I have issues with usb speed now and I need more help to debug this issue.

    I'll describe the problem here but if I need to create a new ticket for this problem, I will.

    The host side is using libusb-1.0, sending 16 X 64  = 1K bytes bulk data from ENDPOINTOUT1  using libusb_bulk_transfer function and after the device receiving 1 KByte data it's sending back the data to the host on ENDPOINTIN1. Data is transferred correctly but the time spent to do just 1 KByte transfer is very long and varying a lot. I measured varying rates from 2 - 100 KBytes/second. I tried various libusb drivers (winUSB, libusb-win32 and libusbK) to see any variation with data rate but didn't see any difference.

    I'm  attaching the main.c for convenience.

    I'm measuring the time spent to send and receive data on the usb device toggling LED's and measuring those using a logic analyzer.  

    Using LED_SEND to measure time spent on ENDPOINTIN1 and using LED_RECEIVE to measure time on ENDPOINTOUT1. 

    My understanding from the nRF52840_PS_v1.0.pdf,  usb has to run with the high frequency clock (which is 64 MHz ?) However even I don't start hfclk in clock_init function (I comment out all clock start and request functions, from line#1030 to line#1040) I don't see any differences with the speed. It varies but it is very slow compared to expected bulk transfer rates.  At this point I don't know how to debug this speed issue further. I'm attaching two captures showing the SEND and RECEIVE times with and without hflck enabled. Can you please help with this?

    Thank you and Best Regards,

    Asli

    USB device receive and send time, hfclk disabled

    USB device receive and send time, hfclk enabled

Children
  • Hi,

    ASLI said:
    I'll describe the problem here but if I need to create a new ticket for this problem, I will.

     I'm leaving for vacation, so I will unfortunately not be able to follow up your question. I would therefore recommend that you create a new ticket for this USB speed issue.

    Edit: For anyone else reading this case, the new case for the speed issue can be found here.

  • Hi ,

      I am also trying to setup communication from BLE chipset through USB 2.0 port to Host Ubuntu PC(USB Port) or on external CPU EVK on USB port. Can you please suggest me this application will work with UBUNTU Host PC ?

  • Hi ratnakar1978,

    Please create a new support case for your question.