Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USB CCID class with nordic nRF52840

I am developing USB CCID driver class for nordic nRF52840. I used USB CDC-ACM class as reference and tried to implement for USB CCID. I have developed the device descriptor for it.

USB CCID class has 1 interface and 3 endpoints(1 for interrupt, 1 for bulk IN and 1 for bulk OUT). Now the windows is detecting as Microsoft Usbccid smart card reader(WUDF)

In modify the app_usbd_ccid_internal.h, i need to know modification to be done in 

1. class instance data (app_usbd_ccid_inst_t)

2. CCID class specific request handled via control endpoint (app_usbd_ccid_req_t)

3.  ccid context (app_usbd_ccid_ctx_t)

I have attached my app_usbd_ccid_internal.h file with tis for refrence.

app_usbd_ccid_internal.h

Parents
  • Hi,

     

    This is a windows feature, that you cannot fix in firmware.

    See a similar issue here, just for the USBD_CDC_ACM: https://devzone.nordicsemi.com/f/nordic-q-a/52438/usb-cdc-uart-is-recognized-as-teensy-com-port

    If you have another driver, you can manually update the driver, as described in the above link.

     

    Kind regards,

    Håkon

  • Hi Håkon,

    This is not the answer for the issue i described above.

    Pls check above issue i have described. 

  • That can potentially happen (ie: the request wasn't for this specific descriptor), which is the reason why all class implementations forward that to the app_usbd_core.c::app_usbd_core_setup_rsp().

    It is hard to tell what happens here, as I do not have all the details. What is the expected vs. actual behavior that you're seeing?

     

    Kind regards,

    Håkon

  • Hi,

    Still, the problem is not cleared, that the program sticks in an infinite loop at this part

    while (app_usbd_event_queue_process())
    {
    /* Nothing to do */
    }

    But I can able to process all the USBD CCID device class functions. I have tested all the CCID functions its working fine. The output of it is given below for your reference. 

    <info> app: USBD CCID example started.
    <info> usbd_ccid: ccid_event_handler app_evt.type = 11
    <info> app: USB power detected
    <info> usbd_ccid: ccid_event_handler app_evt.type = 8
    <info> app: USB ready
    <info> usbd_ccid: ccid_event_handler app_evt.type = 10
    <info> usbd_ccid: ccid_event_handler app_evt.type = 15
    <info> usbd_ccid: ccid_event_handler app_evt.type = 13
    <info> usbd_ccid: ccid_event_handler app_evt.type = 2
    <info> usbd_ccid: ccid_event_handler app_evt.type = 3
    <info> usbd_ccid: ccid_event_handler app_evt.type = 15
    <info> usbd_ccid: ccid_event_handler app_evt.type = 1
    <info> usbd_ccid: ccid_event_handler app_evt.type = 1
    <info> usbd_ccid: ccid_event_handler app_evt.type = 15
    <info> usbd_ccid: ccid_event_handler app_evt.type = 5
    
    <info> usbd_ccid: setup_event_handler
    <info> usbd_ccid: setup_req_std_in
    <info> usbd_ccid: NRF_ERROR_NOT_SUPPORTED
    
    <info> usbd_ccid: ccid_event_handler app_evt.type = 15
    <info> usbd_ccid: ccid_event_handler app_evt.type = 5
    <info> usbd_ccid: setup_event_handler
    <info> usbd_ccid: setup_req_class_in
    <info> usbd_ccid: Data = A1 02 00 00 00 04
    <info> usbd_ccid: APP_USBD_CCID_GET_CLOCK_FREQUENCIES
    
    <info> usbd_ccid: ccid_event_handler app_evt.type = 5
    <info> usbd_ccid: setup_event_handler
    <info> usbd_ccid: setup_req_class_in
    <info> usbd_ccid: Data = A1 03 00 00 00 04
    <info> usbd_ccid: APP_USBD_CCID_GET_DATA_RATES
    
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_ICCPOWEROFF
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_ICCPOWERON
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_GETPARAMETERS
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_XFRBLOCK
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev
    <info> usbd_ccid: PC_TO_RDR_ICCPOWEROFF
    <info> usbd_ccid: ccid_event_handler app_evt.type = 6
    <info> usbd_ccid: ccid_endpoint_ev

    While digging app_usbd_event_queue_process(), this function doesnt return false, because m_sof_events_cnt is 0x0005 every time.

    I don't know why m_sof_events_cnt is 5 every time. 

  • Hi,

     

    Mohammad said:
    But I can able to process all the USBD CCID device class functions. I have tested all the CCID functions its working fine. The output of it is given below for your reference. 

     It sounds like the USB host is polling the USB device for data in a given interval, but the device does not have something to send. This can be verified if you have a usb sniffer trace (if you have a dedicated usb sniffer, like a ellisys usb explorer (https://www.ellisys.com/products/usbex200/) or any other dedicated usb sniffer (totalphase is also popular: https://www.totalphase.com/solutions/apps/usb-analyzer-guide/)

     

    Mohammad said:

    While digging app_usbd_event_queue_process(), this function doesnt return false, because m_sof_events_cnt is 0x0005 every time.

    I don't know why m_sof_events_cnt is 5 every time. 

     This timing interval can be driven by the host. It is a bit unclear to me based on the logs, does everything work as expected?

     

    Kind regards,

    Håkon

  • Hi

     This timing interval can be driven by the host. It is a bit unclear to me based on the logs, does everything work as expected?

    Yes, USB CCID class messages are working fine as expected. Only the problem, it's not coming out of this loop

    while (app_usbd_event_queue_process())
    {
    /* Nothing to do */
    }

  • Hi,

     

    If you have logging enabled, and print many characters over the UART, and the host is polling the usb device for data every 5 frames, I suspect that the usbd_event_queue will always look like it returns true, as it get polled very frequently, and the remainder of the time is spent with handling the NRF_LOG calls.

    Could you try blinking a LED or similar in your main loop to see if it toggles during this state?

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    If you have logging enabled, and print many characters over the UART, and the host is polling the usb device for data every 5 frames, I suspect that the usbd_event_queue will always look like it returns true, as it get polled very frequently, and the remainder of the time is spent with handling the NRF_LOG calls.

    Could you try blinking a LED or similar in your main loop to see if it toggles during this state?

     

    Kind regards,

    Håkon

Children
Related