Help with MQX SDHC support on TWRK60F120M

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

Help with MQX SDHC support on TWRK60F120M

2,977 Views
andrewclegg
Contributor III

Hi, I am getting really stuck with trying to use the built in SDHC slot on the TWRK60F120M. I am trying to use MQX IO drivers for direct block-level access, rather than with MFS.

 

If I try to initialize the SD card support with ProcessorExpert (either SDHC_LDD or Init_SDHC), then I can use the MQX IO driver to open the device:

MQX_FILE_PTR com_handle = fopen(BSP_SDCARD_ESDHC_CHANNEL, NULL); _io_sdcard_install("sdcard:", (void *)&_bsp_sdcard0_init, com_handle); sd_card_ptr = fopen("sdcard:", 0); uint32_t num_sectors; _io_ioctl(sd_card_ptr, IO_IOCTL_GET_NUM_SECTORS, &num_sectors); _io_write(sd_card_ptr, &current_data_block, 512);

This is minimalised code, my real version has error checking etc. I get an sd_card_ptr which is not null. The IOCTL command runs, but the num_sectors is not correct. The _io_write call fails (returns IO_ERROR_WRITE).

 

If I don't use either of the ProcessorExpert components, then the 3rd line (fopen("sdcard:", 0)) fails.

 

So my question is - am I doing anything really stupid here? Do I need the processor expert components to initialize the card, or is this just causing problems? Is it OK to read/write directly to the card without going through MFS? Is there a better way of doing this - all I really need to do is read and write 512 byte blocks to the card?

 

Many thanks

Labels (1)
Tags (3)
0 Kudos
Reply
2 Replies

2,727 Views
andrewclegg
Contributor III

Forgot to say, I'm using the latest versions of everything... CodeWarrior 10.6, MQX4.1 etc

0 Kudos
Reply

2,727 Views
soledad
NXP Employee
NXP Employee

Hi Andrew,

ESDHC device driver provides an installation function _esdhc_install() that either the BSP or the application calls. The function then calls _io_dev_install_ext() internally. Installation function creates internal structures within MQX I/O subsystem and makes the driver available for public use.

So, you don´t need to use processor expert.

MFS is a device driver that an application must install over a lower-level device driver. Examples of lower-level drivers are drivers for memory devices, flash disks, floppy disks, or partition-manager devices etc.

MFS uses the lower-level driver to access the hardware device.

MFS functions do the following:

• Traverse MS-DOS directory structure.

• Create and remove subdirectories.

• Find files.

• Create and delete files.

• Open and close files.

• Read from files and write to files.

• View and modify file characteristics.

• Get the amount of free space in the file system.

If you want to use this functions then you need to use MFS.

You can find an example that you can use as reference,  at the path C:\Freescale\Freescale_MQX_4_1\mfs\examples\sdcard


Have a great day,
Sol

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