This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1290NCPDT: Using USBDFUDevice with USBSerialDevice

Part Number: TM4C1290NCPDT

I am able to use boot_demo_usb on the application PCB and program it with dfuprog. The boot_demo_usb example uses a USB HID device. 

The application uses a USB serial device. If I define a DFU device on the bus, I am not seeing it as a Stellaris DFU device in the device manager, only a USB serial device.

Can you comment on what is missing from the code below?

Thanks,

Priya

void USBmain(void)

{

    uint32_t ui32PLLRate;

 

    //// Enable the USB peripheral

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);

 

    // Configure the device pins.

    PinoutSet(false, true);

 

    // Initialize the transmit and receive buffers.

    USBBufferInit(&g_psTxBuffer[0]);

    USBBufferInit(&g_psRxBuffer[0]);

 

    // Pass the device information to the USB library and place the device

                        // on the bus.

                        //

              g_sCompDevice.psDevices[0].pvInstance =

                       USBDCDCCompositeInit(0, &g_psCDCDevice[0], &g_psCompEntries[0]);

 

 

       // Tell the USB library the CPU clock and the PLL frequency.  This is a

       // new requirement for TM4C129 devices.

       //

       SysCtlVCOGet(SYSCTL_XTAL_25MHZ, &ui32PLLRate);

       UARTprintf("\n ui32PLLRate = %d\n", ui32PLLRate);

       USBDCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock);

       USBDCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);

 

 

       USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_DATA_SIZE + COMPOSITE_DDFU_SIZE,

                                                 g_pucDescriptorData);

       USBDDFUCompositeInit(0, &g_sDFUDevice, &(g_sCompDevice.psDevices[1]));

 

}

 

tUSBDCompositeDevice g_sCompDevice =

{

    //

    // Stellaris VID.

    //

    USB_VID_TI_1CBE,

 

    //

    // Stellaris PID for composite serial device.

    //

 

//    USB_PID_SERIAL,

    USB_PID_COMP_HID_DFU,

 

    //

    // This is in 2mA increments so 500mA.

    //

    250,

 

    //

    // Bus powered device.

    //

    USB_CONF_ATTR_BUS_PWR,

 

    //

    // There is no need for a default composite event handler.

    //

    ControlHandler,

 

    //

    // The string table.

    //

    g_pui8StringDescriptors,

    NUM_STRING_DESCRIPTORS,

 

    //

    // The Composite device array.

    //

    1,

    g_psCompEntries

};

 

#define NUM_SERIAL_DEVICES      2

tCompositeEntry g_psCompEntries [NUM_SERIAL_DEVICES];

  • Hello Priya,

    If you are doing a composite device setup, then you need to use the proper PID for both. In this descriptor, you are using PIDs for a standard USB Serial for single port CDC and a USB composite DFU.

    You should use USB_PID_COMP_HID_SER instead of USB_PID_SERIAL.

  • Ralph,

    Can you take a look at the data structure and descriptor definitions and give me some feedback? 

    Priya

    edited to add DFU structure

    volatile bool g_bUpdateSignalled;

    uint32_t DFUDetachCallback(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgData,
    void *pvMsgData);

    //*****************************************************************************
    //
    // The DFU runtime interface initialization and customization structures
    //
    //*****************************************************************************
    tUSBDDFUDevice g_sDFUDevice =
    {
    DFUDetachCallback,
    (void *)&g_sDFUDevice
    };

    uint32_t
    DFUDetachCallback(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgData,
    void *pvMsgData)
    {
    if(ui32Event == USBD_DFU_EVENT_DETACH)
    {
    //
    // Set the flag that the main loop uses to determine when it is time
    // to transfer control back to the boot loader. Note that we
    // absolutely DO NOT call USBDDFUUpdateBegin() here since we are
    // currently in interrupt context and this would cause critical issues
    // to occur and would not allow the boot loader to work.
    //
    g_bUpdateSignalled = true;
    }

    return(0);
    }

    tUSBDCDCDevice g_psCDCDevice[NUM_SERIAL_DEVICES] =
    {
    {
    USB_VID_TI_1CBE,
    USB_PID_SERIAL,
    // USB_PID_COMP_HID_SER,
    0,
    USB_CONF_ATTR_SELF_PWR,
    ControlHandler,
    (void *)&g_psCDCDevice[0],
    USBBufferEventCallback,
    (void *)&g_psRxBuffer[0],
    USBBufferEventCallback,
    (void *)&g_psTxBuffer[0],
    g_pui8StringDescriptors,
    NUM_STRING_DESCRIPTORS
    }
    };

    tUSBDCompositeDevice g_sCompDevice =
    {
    // Stellaris VID.
    USB_VID_TI_1CBE,
    // Stellaris PID for composite serial device.

    // USB_PID_SERIAL,
    USB_PID_COMP_HID_DFU,

    // This is in 2mA increments so 500mA.
    //
    250,

    // Bus powered device.
    USB_CONF_ATTR_BUS_PWR,

    // There is no need for a default composite event handler.

    ControlHandler,

    // The string table.
    g_pui8StringDescriptors,
    NUM_STRING_DESCRIPTORS,
    // The Composite device array.
    1,
    g_psCompEntries
    };
    uint8_t g_pui8DescriptorData[DESCRIPTOR_DATA_SIZE];
    tCompositeEntry g_psCompEntries [NUM_SERIAL_DEVICES]; // This is extra
    //*****************************************************************************
    //
    // The languages supported by this device.
    //
    //*****************************************************************************
    const uint8_t g_pui8LangDescriptor[] =
    {
    4,
    USB_DTYPE_STRING,
    USBShort(USB_LANG_EN_US)
    };

    //*****************************************************************************
    //
    // The manufacturer string.
    //
    //*****************************************************************************
    const uint8_t g_pui8ManufacturerString[] =
    {
    (17 + 1) * 2,
    USB_DTYPE_STRING,
    'T', 0, 'e', 0, 'x', 0, 'a', 0, 's', 0, ' ', 0, 'I', 0, 'n', 0, 's', 0,
    't', 0, 'r', 0, 'u', 0, 'm', 0, 'e', 0, 'n', 0, 't', 0, 's', 0,
    };

    //*****************************************************************************
    //
    // The product string.
    //
    //*****************************************************************************
    const uint8_t g_pui8ProductString[] =
    {
    2 + (23 * 2),
    USB_DTYPE_STRING,
    'D', 0, 'E', 0, 'V', 0, 'I', 0, 'C', 0, 'E', 0, ' ', 0,
    'F', 0, 'I', 0, 'R', 0, 'M', 0, 'W', 0, 'A', 0, 'R', 0, 'E', ' ', 0,
    'U', 0, 'P', 0, 'G', 0, 'R', 0, 'A', 0, 'D', 0, 'E', 0
    };

    //*****************************************************************************
    //
    // The serial number string.
    //
    //*****************************************************************************
    const uint8_t g_pui8SerialNumberString[] =
    {
    2 + (11 * 2),
    USB_DTYPE_STRING,
    'A', 0, 'M', 0, 'A', 0, 'N', 0, 'O', 0, 'M', 0, 'C', 0, 'G', 0, 'A', 0, 'N', 0, 'N', 0
    };

    //*****************************************************************************
    //
    // The control interface description string.
    //
    //*****************************************************************************
    const uint8_t g_pui8ControlInterfaceString[] =
    {
    2 + (21 * 2),
    USB_DTYPE_STRING,
    'A', 0, 'C', 0, 'M', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0, 't', 0,
    'r', 0, 'o', 0, 'l', 0, ' ', 0, 'I', 0, 'n', 0, 't', 0, 'e', 0,
    'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0
    };

    //*****************************************************************************
    //
    // The configuration description string.
    //
    //*****************************************************************************
    const uint8_t g_pui8ConfigString[] =
    {
    2 + (26 * 2),
    USB_DTYPE_STRING,
    'S', 0, 'e', 0, 'l', 0, 'f', 0, ' ', 0, 'P', 0, 'o', 0, 'w', 0,
    'e', 0, 'r', 0, 'e', 0, 'd', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0,
    'f', 0, 'i', 0, 'g', 0, 'u', 0, 'r', 0, 'a', 0, 't', 0, 'i', 0,
    'o', 0, 'n', 0
    };

    //*****************************************************************************
    //
    // The descriptor string table.
    //
    //*****************************************************************************
    const uint8_t * const g_pui8StringDescriptors[] =
    {
    g_pui8LangDescriptor,
    g_pui8ManufacturerString,
    g_pui8ProductString,
    g_pui8SerialNumberString,
    g_pui8ControlInterfaceString,
    g_pui8ConfigString
    };


    #define NUM_STRING_DESCRIPTORS (sizeof(g_pui8StringDescriptors) / \
    sizeof(uint8_t *))

  • Hello Priya,

    I don't see any structures for the DFU device.

    Refer to our boot_demo_usb example to see how to set up the descriptor structure for tUSBDDFUDevice.

    I still think you will need USB_PID_COMP_HID_SER instead of USB_PID_SERIAL for g_psCDCDevice.

  • Ralph,

    I tried changing to USB_PID_COMP_HID_SER for the  g_psCDCDevice. I can only still see a COM port in the device manager. 

    I have the boot_demo_usb examble working. Please not it uses a USB HID device and not a CDC device. Can you provide an updated example?

    Priya

  • Hello Priya,

    I can see about putting one together but I won't be able to work on that until late this week.

  • I look forward to a boot_demo_usb example that uses only USB CDC device with no reference to USB HID.

    Thanks,

    Priya

  • I am following up on a boot_demo_usb example that uses a CDC device, no reference to HID device.

    Priya

  • Hello Priya,

    Mixed results on what I was able to do. I do have the example put together however, it does not enumerate in Windows properly because we do not have Windows drivers for that sort of composite combination. Providing new Windows drivers is beyond the support capabilities that we can offer.

    The point I am at is identical to your own, I can see the CDC device in Device Manager, but the DFU device does not find suitable drivers to enumerate with.

    At this point, the issues lies with Windows and how to define USB drivers for it, and that is beyond what I can help with.

    If you want the project I put together, I can provide that.

    Best Regards,

    Ralph

  • Ralph,

    Thank you for your reply. Yes, please provide the example project you put together for the composite CDC device.

    Priya

  • Hi Priya,

    I want to clean up the example a bit more and didn't finish that today, I will have the project for you tomorrow. Since other E2E users may reference this I want to make sure it isn't as thrown together as I had it.

    Best Regards,

    Ralph

  • Hello Priya,

    Please find the example project attached. CDC works as it enumerates, but DFU does not enumerate due to Windows Driver issue:

    usb_dev_cdc_dfu.zip