AnsweredAssumed Answered

Kinetis K64 Unknown USB Device After Application Launch

Question asked by Benjamin Sanda on Dec 20, 2018
Latest reply on Dec 20, 2018 by Mark Butcher

We're running a custom board with a K64 and the KSDK 2 USB stack. The system is running a custom bootloader which initializes a virtual com over USB CDC to a windows PC. The bootloader then launches an application which also uses a virtual com over USB CDC. Both the bootloader and app use the KSDK USB stack. The issue we see is as follows:

1. Start bootloader: The windows PC sees the virtual com and enumerates it properly and we can communicate over it.

2. Pre-application launch: The bootloader de-initializes the USB com (see code below). The com port disappears from Windows.

3. Bootloader launches application: The bootloader launches the application. The application code re-initializes the virtual com. In Windows, however; we get "Unknown USB Device (Device Descriptor Request Failed" with Code 43. We can plug/unplug the USB port at this point and it still doesn't enumerate properly.

 

To verify the application code is working properly we also tested a version of the bootloader which does not initialize the USB com. The bootloader comes up, performs no USB functionality, and then launches the application. In this case Windows properly enumerates the USB com and we can talk with the application.

 

The issue only appears when both the bootloader and application initialize the USB com. Initially we didn't have the bootloader de-init the com before jumping, and then added in the de-init hoping that would fix the issue but it hasn't. Searching the forums it seems there are known issues with re-connecting/disconnecting USB coms on these devices with little resolution. Has anyone encountered a similar issue?

 

This is the code which de-inits the com before application launch:

void VCOM_DeInit(void)
{
uint8_t irqNo;
uint8_t khciIrq[] = USB_IRQS;
irqNo = khciIrq[CONTROLLER_ID - kUSB_ControllerKhci0];

 

USB_DeviceSetDefaultState(s_cdcVcom.deviceHandle);
USB_DeviceStop(s_cdcVcom.deviceHandle);
USB_DeviceClassDeinit(CONTROLLER_ID);

 

HAL_CpuIrqUnregister(irqNo);
DisableIRQ((IRQn_Type)irqNo);
}

Outcomes