Is it possible to use dual SD card in K60?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Is it possible to use dual SD card in K60?

跳至解决方案
1,562 次查看
danielchai
Senior Contributor I

Hi All,

Is it possible to use dual sd card in K60F120 through MQX?

Thanks.

-Daniel

0 项奖励
回复
1 解答
1,224 次查看
CarlosCasillas
NXP Employee
NXP Employee

Hi Daniel,

MQX’s MFS library is able to mount multiple drives. I haven’t tested it with 2 SD cards, but I verified that it works with 2 USB sticks connected on a HUB, applying the following changes to the mfs_usb example:

USB_Task.c -> USB_task(uint32_t para):

uint32_t fs_mountp = 0; changed to static uint32_t fs_mountp = 0;

Here is the log of the serial terminal showing the two drives:

twousbs.png
Hope this will be useful for you
Best regards!
/Carlos

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

在原帖中查看解决方案

0 项奖励
回复
8 回复数
1,224 次查看
CarlosCasillas
NXP Employee
NXP Employee

Hi Daniel,

Yes, you could use two SD cards on MQX. However, as the K60F120 device just have one SDHC module, the other card should be accessed using an SPI module (configure each file pointer properly).


Hope this will be useful for you
Best regards!
/Carlos

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

0 项奖励
回复
1,224 次查看
danielchai
Senior Contributor I

Hi Carlos,

If I configure the first SD card using SDHC and second one using SPI and install the MFS on both of them, they should work without conflict, is it corrrect?

Thank you.

-Daniel

0 项奖励
回复
1,225 次查看
CarlosCasillas
NXP Employee
NXP Employee

Hi Daniel,

MQX’s MFS library is able to mount multiple drives. I haven’t tested it with 2 SD cards, but I verified that it works with 2 USB sticks connected on a HUB, applying the following changes to the mfs_usb example:

USB_Task.c -> USB_task(uint32_t para):

uint32_t fs_mountp = 0; changed to static uint32_t fs_mountp = 0;

Here is the log of the serial terminal showing the two drives:

twousbs.png
Hope this will be useful for you
Best regards!
/Carlos

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

0 项奖励
回复
1,224 次查看
danielchai
Senior Contributor I

Hi Carlos,

Is it possible to use SPI instead of ESDHC on the TWR-K60F120 board in MQX?

If yes, how should I configure it to use SPI instead of ESDHC.

Thank you.

-Daniel

0 项奖励
回复
1,224 次查看
dereksnell
NXP Employee
NXP Employee

Hi Daniel,

Yes, MQX is setup to use the SPI driver for the sdcard driver. You can refer to the SD Card Driver chapter in the MQX IO User Guide for more details, installed with MQX at \doc\mqx\MQX_IO_User_Guide.pdf

Also, the MFS sdcard example at \mfs\examples\sdcard will work with the SPI driver as well. Refer to demo.c for this example. If the BSP does not have the SDHC driver installed, the example will attempt to use the SPI driver.

Thanks

0 项奖励
回复
1,224 次查看
danielchai
Senior Contributor I

Hi Derek,

That's what I thought when I read the MQXIOUG.pdf. But when I tried to use the example under \mfs\examples\sdcard, it required to enable the BSP_SDCARD_ESDHC_CHANNEL in user_config.h. And I checked the init_sdcard.c file, it seems it only use the esdhc no spi.

And I searched the whole MQX, there is no definition for BSP_SDCARD_SPI_CHANNEL.

Thank you.

-Daniel

0 项奖励
回复
1,224 次查看
dereksnell
NXP Employee
NXP Employee

Hi Daniel,

The BSPs for the Kinetis devices with the SDHC peripherals do not define the macro BSP_SDCARD_SPI_CHANNEL, since they use SDHC.  But if you search the MQX source code for BSP_SDCARD_SPI_CHANNEL, you will find there are Kinetis BSPs that use it.  For example, the twrk20d72m BSP has this macro defined because this Kinetis device does not include the SDHC peripheral, and the BSP is setup to use the SPI driver for the SDCARD driver.

I was able to use the twrk20d72m BSP as a reference, and modified the twrk60f120m BSP to use the SPI driver instead of SDHC.  And then I tested with the MFS example \mfs\examples\sdcard to test this with the TWR-K60F120M board.  This was with MQX v4.1.0.  Attached are the files I modified, with a brief description below:

  • User_config.h – Disable the BSPCFG_ENABLE_ESDHC driver macro and enable BSPCFG_ENABLE_SPI
  • Twrk60f120m.h – Update the BSP_SDCARD macros for the SPI peripheral, chip select, and pins connected to the sdcard
  • Init_sdcard.c – Change the SDCARD driver initialization structure to use the SPI SDCARD functions, as described in the MQX IO User Guide
  • Init_gpio.c – Change the SPI pins and pin mux settings for the BSP

Thanks

0 项奖励
回复
1,224 次查看
danielchai
Senior Contributor I

Hi Carlos,

Thanks. That helps.

-Daniel

0 项奖励
回复