AnsweredAssumed Answered

Standalone bare metal USB MSD  with K64F, KSDK-1.1.0 and KDS 2.0.0, SDHC and fatfs

Question asked by Jeff Gough on Apr 28, 2015
Latest reply on Aug 1, 2017 by Neil Porven


I am using a K64F120 in a bare metal configuration on a custom PCB. It has an SD card on the SDHC bus which will be used for storage. When plugged in to USB it should behave like a mass storage device. When unplugged, my application will be creating files on the SD card using fatfs, rather like a datalogger.


I am currently trying to get the USB part working with the RAM disk example. I have placed a fsl_usb_framework PE component in my project (with auto-initialise disabled) to get KDS to include the right bits of the USB library into my build. I want to create a stand-alone project that can compile without references to the KSDK installation directory. I want the whole source tree in a single git repository.


I have copied disk.c, disk.h, usb_descriptor.c and usb_descriptor.h from the KSDK_1.1.0/usb/example/device/msd into my Sources folder, and everything compiles fine.


I've stepped through the init code with _DEBUG set, and the USB class and device initialises OK with no errors.


However, when I plug in a USB cable, nothing happens. I'm running Linux on my PC, so I can look in dmesg and lsusb for information, but there appears to be nothing happening at all on the USB bus.


I have added debug UART printf output to USB_App_Class_Callback and USB_App_Device_Callback. They fire during the initialisation process, but not when I plug/unplug a USB cable.


I've copied the electrical design from the FRDM-K64 schematic, so I'm confident there are no electrical problems with the USB connection.


I am running the K64 from a 12MHz crystal and a system frequency of 120MHz. I haven't changed anything in bsp_usb_dev_init, but I think it's set up right for 120MHz * 2 / 5 = 48MHz.


Any ideas? Please don't suggest using uTasker!


Many thanks