Hardware and software configuration:
KSDK 1.2 provides an Eclipse update for those who want to use the Kinetis SDK with Eclipse and Processor Expert. and with this update , users may find MSD Class component has been supported, and there is a simple USB mass storage demo available directly in this PEx USB component, so that customers may easily build this demo and develop their own application based on that.
Here I will start to illustrate how to implement this demo step by step.
As FRDM-K22F is used in this test, so I directly choose this board and make the following configuration:
After above steps, we have a PEx project with some pre-installed components as shown below:
clockMan1 components has 6 configurations , and one of it is for USB application, you may set it as the init configuration right now, or it would be set automatically when you add the USB MSD components.
Now I find the MSD component from KSDK 1.2 and add it to my project:
This component will add 4 more reference components into this project, and we only have to configure the component "fsl_debug_console" to get rid of the error mark.
For FRDM-K22 board, UART1 is used as the debug console, and PTE0 and PTE1 are used as the TXD and RXD, so I set up this components as below:
The simple MSD demo is a RAM disk demo, and it is disabled by default, so we have to enable it in the fsl_usb_device_msd_class component, and the demo code will be automatically added into the project afterwards:
and then set the correct PID and VID information in the component of fsl_usb_descriptors.
so far looks like all components are configured correctly , but if we directly download this application, we will have an enumeration issue like below:
This is due to USB descriptors are placed to Flash memory area by default . You know , USB descriptors contain constant values so storing them in flash would leave more RAM for user application. The highlighted option in the following figure determines this .
but USB module in Kinetis doesn't have the permission for flash out of reset, so we still have something to do before going ahead.
There are several solutions for it, the most easiest way is setting the above option to "no", but we may do it in a PEx-like way by using the "Init_FMC" component.
Please note USB is the M4 of K22's crossbar-lite. so we give it the "read only" permission.
Init_FMC() is placed in Peripherals_Init() which is called right before Components_Init() where USB_Class_MSC_Init () is in, so it guarantees USB have the flash access permission before it starts up.
Now the demo can work well with the PC host, just as shown below:
So far only HID and MSD Class components are supported, and if you go through a similar process as above, you may easily implement a HID demo by yourself. Here I attach both the MSD and HID mouse demo for your reference.
Hope that helps,
Exceptional walk-through using PEx to implement a KDS component. This is exactly the kind of documentation we need for each KDS component.
Takes you step by step through the process of setting up a functional component, with a simple explanation as to why we are taking each step.
Example projects are nice; but, not very useful for helping you setup that one component you need.
Thank you for providing this concise document!
Nice tutorial!
I would like to do it adding SDHC Card detection on computer as MSD did you do it?
Regards,
Loïc
Is there no support for this example in SDK1.3? I can´t make it work either.
Is it possible it solve the enumeration and formatting issues using something other than the FMC? I've been trying to get this to work on a MKL27Z. The demo works on the dev board, but the formatting is not allowed to complete. When I try the same code on my project I get the enumeration error.
Thank you for any help you can provide.
Same problem with by board. I need help for a product that we are developing, can nxp support help us?!....
Here my port https://community.nxp.com/thread/448886