Hi All,
I edit the code for msd_usb from RAM to SD card. Now my problem is that every time when I plug in the USB cable to my PC, it asks me to format. But I can not format it. It seems there is something wrong.
I just edit
From
case USB_MSC_DEVICE_READ_REQUEST :
lba_data_ptr = (PTR_LBA_APP_STRUCT)val;
#if RAM_DISK_APP
USB_mem_copy(g_disk.storage_disk + lba_data_ptr->offset,
lba_data_ptr->buff_ptr,
lba_data_ptr->size);
#endif
break;
case USB_MSC_DEVICE_WRITE_REQUEST :
lba_data_ptr = (PTR_LBA_APP_STRUCT)val;
#if RAM_DISK_APP
USB_mem_copy(lba_data_ptr->buff_ptr,
g_disk.storage_disk + lba_data_ptr->offset,
lba_data_ptr->size);
#endif
break;
TO
case USB_MSC_DEVICE_READ_REQUEST : |
lba_data_ptr = (PTR_LBA_APP_STRUCT)val;
fread(lba_data_ptr->buff_ptr, 1, 1, filesystem_handle);
break; |
case USB_MSC_DEVICE_WRITE_REQUEST :
lba_data_ptr = (PTR_LBA_APP_STRUCT)val;
fwrite(lba_data_ptr->buff_ptr, 1, 1, filesystem_hanlde);
break;
I am new to this, any ideas will be appreciated.
Thank you.
-Daniel
已解决! 转到解答。
Hi Daniel,
Attached you can find a simple SD card reader via USB using MQX. It is working but I just want you to know that the format is really slow. This one does not implement multi read/write blocks, and the performance may vary depending on the SD you are using.
This project is a little bit old, because it works in CW10.1 and K60 with MQX v3.7, but you can use it as reference.
Hope this will be useful for you.
Best regards!
/Carlos
Hi Daniel,
Attached you can find a simple SD card reader via USB using MQX. It is working but I just want you to know that the format is really slow. This one does not implement multi read/write blocks, and the performance may vary depending on the SD you are using.
This project is a little bit old, because it works in CW10.1 and K60 with MQX v3.7, but you can use it as reference.
Hope this will be useful for you.
Best regards!
/Carlos
Hi Daniel,
did you get this going?
I tried it on the K64F120 and get the format problem.
When I read sector by sector using USB, each time I do it the data is different and not always the the same as what is on the SD.
Cheers,
Lisa
Hi Lisa,
Actually, this code does not work. I contacted the one of the Freescale engineer, he said the read/write on the SD card can not be called in the USB reading/writing request, because all the functions in USB reading/writing function should be non-blocking function. When you debug into very deep level, it
will show you the Errorcode which indicate the function can not be called in current context.
-Daniel
Hi Daniel,
many thanks. Did you work out a solution?
I found that I
read most of the data but some is corrupted or appears to be in the
wrong place.
If USB reads should be non blocking, what should be
returned from the function? I assume there is some other way that the
data can be sent then rather than return from the function.
I will need
to investigate further.
Cheers,
Lisa
On 14/04/2014 21:07, Daniel Chai
wrote:
USB MASS STORAGE DEVICE FROM SD CARD WITH TWR-K60
reply
from Daniel Chai in _ Kinetis Microcontrollers_ - View the full
discussion
Take a look at this thread https://community.freescale.com/message/372336#372336
Hi pramodk.g.,
I also was able to make it work. But as you stated, data rate is really really slow... Have you been able to improve it?
Thanks
Mirco