How to implement a USB Device MSD demo based on KSDK PEx components and KDS 3.0

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to implement a USB Device MSD demo based on KSDK PEx components and KDS 3.0

How to implement a USB Device MSD demo based on KSDK PEx components and KDS 3.0

Hardware and software configuration:

  • FRDM-K22F, SCH-28164 REV D
  • OpenSDA: J-Link firmware
  • KDS 3.0 with SDK 1.2.0 Eclipse update installed

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.

Untitled.png

As FRDM-K22F is used in this test, so I directly choose this board and make the following configuration:

Untitled.png

Untitled.png

After above steps, we have a PEx project with some pre-installed components as shown below:

Untitled.png

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.

Untitled.png

Untitled.png

Now I find the MSD component from KSDK 1.2 and add it to my project:

Untitled.png

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.

Untitled.png

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:

Untitled.png

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:

Untitled.png

and then set the correct PID and VID information in the component of fsl_usb_descriptors.

Untitled.png

so far looks like all components are configured correctly , but if we directly download this application, we will have an enumeration issue like below:

Untitled.png

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 .

Untitled.png

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.

Untitled.png

Untitled.png

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:

Untitled.png

Untitled.png

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,

Labels (1)
Attachments
Comments

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

Hi Kan Li

Is this work on KSDK1.3.0?

I implement it on my FRDM-K22F ,but not works.

Thanks.

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 

No ratings
Version history
Last update:
‎06-18-2015 12:23 AM
Updated by: