I am trying to read data from SD card (Sandisk 4 GB) using eSDHC driver . I am not able to read complete file if file size is more than 1 MB..
I tried below:
1) decrease the speed in the sdhc conf structure (mqx/bsp/<board>/init_sdhc0.c file).
const ESDHC_INIT_STRUCT _bsp_esdhc0_init = {
0, /* ESDHC device number */
25000000, /* ESDHC baudrate */ >>>>>>>>>>>>>>> change this to the 4000000 <<<<<<<<<<
BSP_SYSTEM_CLOCK /* ESDHC clock source */
};
Also change to baudrate = 10000000, baudrate = 1000000, baudrate = 100000, baudrate = 10000, baudrate = 1000, baudrate = 100 .
if (ESDHC_OK != ioctl (sdcard_ptr->COM_DEVICE, IO_IOCTL_ESDHC_GET_BAUDRATE_MAX, &baudrate))
{
return FALSE;
}
//baudrate = 10000000; <-- Here i did the change
if (param > baudrate)
{
param = baudrate;
}
if (ESDHC_OK != ioctl (sdcard_ptr->COM_DEVICE, IO_IOCTL_ESDHC_SET_BAUDRATE, ¶m))
{
return FALSE;
}
2) disable and enable interrupt
In esdhc_read() beginning at around line 1554:
In esdhc_write() beginning at around line 1692:
But still no luck ..
Can anyone please help me where I am doing wrong / or any other solutions ??
Hi soham:
This issue maybe related with MQX-4146.
It is a known issue that MQX 4.1 has some MFS issues.
I woulds suggest you update to MQX 4.2, and patch MQX 4.2.0.2.
I hope it helps
Regards
Daniel
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Also my problem is very sporadic .. it will fail after 20-30 times of file read write
Hi Soham:
You can compare below folder.
Freescale_MQX_4_2\mfs\source
Sorry I don't know the exact files.
Regards
Daniel
Hi Daniel ,
I can see in 4.1 ,
file name mfs_init.c function name _io_mfs_write() line number , approx. 813 ..looks like
#if MQX_USE_IO_OLD
file_ptr->ERROR = errcode;
/* Check for EOF. The MFS EOF must be translated to the standard EOF */
if (result == MFS_NO_ERROR && errcode == MFS_EOF)
{
file_ptr->FLAGS |= IO_FLAG_AT_EOF;
/* Update the file size in the old IO structure */
file_ptr->SIZE = handle->SIZE; <------ here update the file_ptr size
}
return (errcode == 0 || errcode == MFS_EOF) ? result : IO_ERROR;
in
4.2
the file size updated by
/* Update location and file size in the FIO structure - legacy compatibility */
file_ptr->LOCATION = handle->LOCATION;
file_ptr->SIZE = handle->DIR_ENTRY->FILE_SIZE;
/* Check for EOF. The MFS EOF must be translated to the standard EOF */
if (result == 0 && errcode == MFS_EOF)
{
file_ptr->FLAGS |= IO_FLAG_AT_EOF;
}
I took the changes , but still not resolves my issue ...approx. 20-30 iteration ,my file read operation is failing .
Any idea ?
I would suggest you first test this issue with MQX 4.2, and patch. If this version fixed this issue, then you can merge this fix to your code.
Regards
Daniel
sure , let me test that
Thanks :smileyhappy: .
I will check and post my result
Thanks for your reply.
Unfortunately In our project we can not update MQX 4.2 immediately .
Can you tell me the changes /(file name ). I am trying to compare the difference in between 4.1 and 4.2
It will be great if you can tell me the specific file/files name regarding this bug fix