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

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

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

2,636 Views
jeffmakes
Contributor II

Hi

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

Jeff

Labels (1)
Tags (2)
8 Replies

1,101 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Jeff Gough:

You can find attached a pair of standalone projects which may serve you as reference. :smileyinfo: Please notice I used the latest tools: KSDK v1.2 and KDS v3.0, so they may be useful for other people. One of the projects is using Processor Expert while the other is the standalone version of the example project "dev_msd_disk_frdmk64f_bm_frdmk64f".

Some notes to have in mind:

1- Both projects are for the FRDM-K64F and both are using the external 50 MHz reference clock. You need to change MCG clocking for your custom board, let me know if you have problems.

2- The Processor Expert version does not include the SD Card part, only the RAM Disk example.

3 - Having the KSDK platform + KSDK USB stack in a standalone No-PEx project is doable but it requires that you have some familiarity with the KSDK files and folders structure (drivers, hal, includes, etc...). Also you need to know the basics of project handling with the required IDE, in this case KDS. Processor Expert saves a lot of time adding the necessary files and setting the search paths.

I hope this helps.


Regards!,
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,101 Views
neilporven
Senior Contributor I

Hi Jorge,

I downloaded the frdmk64_usb_msd.zip and I imported into my Project Explorer folder, but when I compile it, it comes

back with errors:

Errors.jpg

Is there anything that needs to be done?  Is this a self run project?

Thanks,

Neil

0 Kudos

1,101 Views
neilporven
Senior Contributor I

Update,

If I use the K64_SDK_USB_PE standalone it compiles and runs.  The only problem, I see is that in Windows 7, the projects keeps asking to FORMAT.  If I take it to an XP PC, then it lets me copy a file into it, disconnect it, re-connect it and I am able to retrieve the file.  

I have a question as to what clock source is the project using on the FRDM board?  I tried the same project on my

custom board, but it didn't work and I am thinking it could be the clock source that it is using is different from the one our

custom board uses.

Thank you,

Neil

0 Kudos

1,101 Views
neilporven
Senior Contributor I

Update,

I found that the clock source is 50MHz and it comes from an onboard chip Ethernet PHY.  I injected this 

clock source on our board and now our board also works.  Both our custom board and the FRDM-K64F eval

board display the same behavior.  After detection, a message pop-up screen appears asking to Format the drive,

but once this is done, if I load it with a small file, eject the device from the PC and re-connected it again the same

message appears asking for Format.  If you select Cancel, you can't open the drive to look at the file I just saved.

Anyone has tried this?

Thank you,

Neil

0 Kudos

1,103 Views
gionny
Contributor II

Hi!

Is there a DEMO as "K64_SDK_USB_PEx.zip" that uses sd card and not ram disk?

Thanks

Gionatha

0 Kudos

1,103 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Ferrari Gionatha:

The MSD code using the SD Card is also attached to my previous post. If you mean a version with Processor Expert, unfortunately that is not available.

Regards!

Jorge Gonzalez

0 Kudos

1,103 Views
gionny
Contributor II

Hi Jorge

Yes, I have hoped in a mix...: PEx + USB + SD card

Gionatha

0 Kudos

1,103 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Ferrari Gionatha,

This post might be helpful:

Creating a New USB project with KSDK and Processor Expert support in KDS

It explains how to add Processor Expert support to a USB baremetal project.

Regards!

Jorge Gonzalez

0 Kudos