KSDK 1.3.0 + PEx - Adding SD card with MFS on SPI

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

KSDK 1.3.0 + PEx - Adding SD card with MFS on SPI

759 Views
Vagni
Contributor IV

On my custom board based on K66F180 cpu I have to handle SD cards through the SPI interface.

I am developing my application with KDS 3.0.0 and KSDK 1.3.0 + PEx. My application is based on MQX RTOS Standard and I created my project following the tutorials How To: Create an MQX RTOS for KSDK project with Processor Expert in Kinetis Design Studio IDE and How To: Create an MQX RTOS for KSDK project with Processor Expert in Kinetis Design Studio IDEHow to add RTCS to a Processor Expert Project Using KDS and KSDK .

 

The example projects that come with MFS library for KSDK use the SDHC internal controller.

I am looking for a tutorial for KSDK on how to add SDcard component based on SPI.

 

Thank you.

Labels (1)
0 Kudos
2 Replies

301 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Alessandro Vagniluca:

I am sorry that your thread has been unanswered for a long time.

For the MFS filesystem, unfortunately there is no support for using SPI instead of the SDHC module.

If your project does not require MQX, then you can use FatFs filesystem with the SD Card SPI driver. The example in the next document uses the FatFs library together with the SDHC driver, but the files for SPI mode are provided in the composite folder of KSDK so it can be implemented:

FatFs + SDHC data logger with KSDK in Kinetis Design Studio

SPI files:

C:\Freescale\KSDK_1.3.0\platform\composite\inc\fsl_sdcard_spi.h

C:\Freescale\KSDK_1.3.0\platform\composite\src\sdcard\fsl_sdcard_spi.c

There is also a tutorial on the web if you wish to use Processor Expert:

FRDM K64F Data Logger using FatFs with KSDK 1.2.0 | Centaurian

Regards!

Jorge Gonzalez

0 Kudos

301 Views
Vagni
Contributor IV

Thanks Jorge.

Meanwhile, I also added a USB Host MSD port to my K66-based custom hardware. Now I need to handle both an SD card on SPI and a memory stick on USB.

In the past I developed a similar application on a K60-based custom hardware using MQX 4.x with its drivers based on MFS for both SD card through SPI and USB memory stick.

So in my current project with PEx I started adding the fsl_sdcard and fsl_usb_framework components, but I don't know how to use them. Can you help me?

I configured the fsl_sdcard component selecting fsl_dspi as inherited driver.

I checked auto initialization for the fsl_sdcard component (is it right?).

I configured the fsl_dspi inherited driver and checked auto initialization also for it.

I see PE generates code for auto initialization the fsl_sdcard component and fsl_dspi inherited driver and I get spi_dspi_layer.c new file in my source folder.

How should I use this generated source file with FatFs or MFS?

I see also a fsl_dspi1_IrqHandler() function is generated in my Events.c source module. Should I add some code into that function?

I configured the fsl_usb_framework component with auto initialization (is it right?) and Host mode enabled with USB_CLASS_MASS_STORAGE as class code, USB_SUBCLASS_MASS_UFI as sub-class code and USB_PROTOCOL_MASS_BULK as protocol.

In the fsl_usb_framework component I keep checked MCU and FMC settings (but I don't know their function and use), I checked Host mode request only and  I selected USBCFG_HOST_MCS Host class driver only in Host mode USB stack setting, keeping all the rest at default.

In the cpu.c file generated by PEx the fsl_usb_framework component is initialized calling usb_host_init() and usb_host_register_driver_info() host methods.

And then?

I see also usbFmw1_usb_host_board_init() and usbFmw1_ClassDriver0() functions are generated in my Events.c source module and I should add my code inside them. How should I use them? How should I link FatFs or MFS to the USB Host?

So, is FatFs now the best choise than MFS to handle both SD cards and USB memory sticks on the same platform?

Best Regards,

Alessandro

0 Kudos