k70 with MQX 4.1 . SD card read issue (For bigger file Size > 1MB)

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

k70 with MQX 4.1 . SD card read issue (For bigger file Size > 1MB)

3,972 次查看
sohamd
Contributor I

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, &param))

    {

        return FALSE;

    }

 

2) disable and enable interrupt

In esdhc_read() beginning at around line 1554:

  1. #if ESDHC_IS_HANDLING_CACHE  
  2.     _int_disable();  
  3.   
  4.   
  5.     if (head_len)  
  6.     {  
  7.       _DCACHE_INVALIDATE_LINE(head);  
  8.       _mem_copy(head, data_ptr, head_len);  
  9.     }  
  10.   
  11.   
  12.     if (body_len)  
  13.     {  
  14.         _DCACHE_INVALIDATE_MBYTES(body, body_len);  
  15.     }  
  16.   
  17.   
  18.     if  (tail_len)  
  19.     {  
  20.       _DCACHE_INVALIDATE_LINE(tail);  
  21.       _mem_copy(tail, ((uint8_t *)data_ptr) + head_len + body_len, tail_len);  
  22.     }  
  23.   
  24.   
  25.     _int_enable();  
  26. #endif  
  27.     {  
  28.       _DCACHE_INVALIDATE_LINE(tail);  
  29.       _mem_copy(tail, ((uint8_t *)data_ptr) + head_len + body_len, tail_len);  
  30.     }  

 

In esdhc_write() beginning at around line 1692:

  1.     _int_disable();  
  2.      
  3.     /* Flush caches */  
  4.     if (head_len)  
  5.     {  
  6.         _mem_copy(data_ptr, head, head_len);  
  7.         _DCACHE_FLUSH_LINE(head);  
  8.     }  
  9.   
  10.   
  11.     if (body_len)  
  12.     {  
  13.         _DCACHE_FLUSH_MBYTES(body, body_len);  
  14.     }  
  15.   
  16.   
  17.     if (tail_len)  
  18.     {  
  19.         _mem_copy(((uint8_t*)data_ptr) + head_len + body_len, tail, tail_len);  
  20.         _DCACHE_FLUSH_LINE(tail);  
  21.     }  
  22.   
  23.       _int_enable();  

But still no luck ..

Can anyone please help me where I am doing wrong / or any other solutions ??

标签 (2)
0 项奖励
回复
8 回复数

3,757 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi   soham:

This issue maybe related with MQX-4146.

pastedImage_1.png

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.
-------------------------------------------------------------------------------

0 项奖励
回复

3,757 次查看
sohamd
Contributor I

Also my problem is very sporadic .. it will fail after 20-30 times of file read write

0 项奖励
回复

3,757 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi Soham:

You can compare below folder.

Freescale_MQX_4_2\mfs\source

Sorry I don't know the exact files.

Regards

Daniel

0 项奖励
回复

3,757 次查看
sohamd
Contributor I

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 ?

0 项奖励
回复

3,757 次查看
danielchen
NXP TechSupport
NXP TechSupport

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

0 项奖励
回复

3,757 次查看
sohamd
Contributor I

sure , let me test that

0 项奖励
回复

3,757 次查看
sohamd
Contributor I

Thanks :smileyhappy: .

I will check and post my result

0 项奖励
回复

3,757 次查看
sohamd
Contributor I

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

0 项奖励
回复