AnsweredAssumed Answered

RT1050 - USB CDC host not working on USB2

Question asked by David Rodgers on Jan 6, 2020
Latest reply on Jan 7, 2020 by David Rodgers

So, this isn't a bug report, as far as I can tell.  I'm simply trying to get the USB CDC host function working on a custom RT1050 board, and having no luck in getting any sort of activity out of the EHCI host driver function.  Hopefully someone might have some advice on what I might be doing wrong.


I have a custom RT1050 board (call it the "MCU") that pretty much works as intended, with QSPI boot flash (on the secondary pins, no less), several LPUART, LPSPI, and LPI2C ports, one eMMC device on an SDHC controller, battery-backed RTC, Ethernet, etc., all running under FreeRTOS.  What I'm trying to get working is the USB host function, specifically to get a single CDC port working.  We have another board (call it the "APU") based on a Kinetis K24 with a USB device function, and that board talks fine to a PC over USB.  Under ideal circumstances, the MCU and APU are plugged into a common backplane, which connects their USB port pins together (DP to DP, DN to DN), allowing the MCU to be a USB host to the APU's USB device.


I'm using the MCU Config Tools to create the USB Host peripheral in the project.  Here's the CIC setup:

USB2 host, CIC function

The DIC is also the default setup.  I did have to manually edit usb_host_app.h to change the EHCI instance from 0 to 1; I have a separate thread on that here.  (I'm currently using SDK 2.7.0. and MCUX 11.1.0.)  For what it's worth, I have all caching disabled, because of earlier difficulties encountered while developing Ethernet and SD/MMC code.


What's happening is... well, basically nothing is happening.  I originally built up some code around the auto-generated code to do specifically what I want to do, but since that wasn't working, for test purposes I disabled my custom code and instead called directly into the auto-generated code with no modifications.  So at startup I call BOARD_InitUsb (the peripheral group containing my USB host instance), which calls USB2_APUHost_init(), which calls USB_HostApplicationInit().

usb_status_t USB_HostApplicationInit(void)
usb_status_t status;
status = USB_HostInit(USB_HOST_CONTROLLER_ID, &g_HostHandle, USB_HostEvent);
if (status != kStatus_USB_Success)
return status;
} else {
return status;

I've verified that USB_HostInit() returns OK (and thus USB_HostInterface0CicVcomInit() is called).  Later I create a FreeRTOS task that has this as its entry point:

extern "C"
void USB_HostTaskEntry(void * param) {
while (true)

USB_HostTasks() (in usb_host_app.c) is simply this:

void USB_HostTasks(void)

And I haven't modified USB_HostTaskFn() or USB_HostInterface0CicVcomTask().  My issue is that when I launch the task, and USB_HostTaskFn() gets here:

void USB_HostEhciTaskFunction(void *hostHandle)
usb_host_ehci_instance_t *ehciInstance;
uint32_t bitSet;
usb_device_handle deviceHandle;

if (hostHandle == NULL)
ehciInstance = (usb_host_ehci_instance_t *)((usb_host_instance_t *)hostHandle)->controllerHandle;

if (OSA_EventWait(ehciInstance->taskEventHandle, 0xFF, 0, USB_OSA_WAIT_TIMEOUT, &bitSet) ==
KOSA_StatusSuccess) /* wait all event */
if (bitSet & EHCI_TASK_EVENT_PORT_CHANGE) /* port change */

The call for OSA_EventWait() blocks forever.  It never gets a single event.  The USB2 OTG ISR also never fires.  It's as if the USB peripheral is completely dead.


I've been able to run the "host_cdc_bm" example on the EVKB, and it does recognize the "APU" USB device, so the Kinetis on that board is doing what it's supposed to.  I've compared the code between that example and my application, and I can't find any real differences between the two, either in initialization or operation.  Now, what's not entirely helpful is that there is no "host_cdc_freertos" example, so I can't be sure if I'm supposed to be doing something different because I'm running in FreeRTOS instead of bare-metal.


Anyone have any ideas where I should start looking?  (Probably my next experiment will be to try to get the "host_cdc_bm" example running directly on my target hardware.  Not trivial, since my peripheral selections are different, and I'm running QSPI flash.)


David R.