Hi,
I would like to make K66 development board as the device, and USB stick, connecting to Micro USB port, as the host. Then writing the files from the USB stick to the SD card. Is there an example for this purpose? If not, which one is the closest example I can modify.
Thanks!
I am trying to modify the codes in host_msd_fatfs.c file in order to add SDDISK works together with USBDISK. There is no error when I use f_mount function to add the SDDISK.
However, when I tried to create & open a file on the SDDISK, it always return error code. I have tried f_open(&file1, "2:file.bin", FA_WRITE | FA_READ | FA_CREATE_ALWAYS), f_open(&file1, test_file_name1, FA_WRITE | FA_READ | FA_CREATE_ALWAYS) where test_file_name1 is from sprintf(test_file_name1, "%c:", SDDISK + '0').
Then I look at the example in sdcard_fatfs, and tried to use make file function like f_mkfs(....), the result is similar to the f_open, always return an error code.
What am I missing?
Hello Charles,
Its possible that it may have to do with the string that is placed for the path and how it is taken.
Please take a look at the following post and try the different option to see if this is your case as well.
If it does not work please let me know.
Best Regards,
Sabina
Hi Sabina,
Thanks for your reply. I have figured out the reason why FATfs is not working. It is because the SD card was not initialized. I found the boolean variable "g_sd_isHostReady" was Null.
Then I tried to add function "sdcardWaitCardInsert()" and associated files, however, it causes bus_fault and hard_fault after calling function "Port_SetPinInterruptConfig()". I have attached several screenshots for the variables when this function is called, as well as the screenshot when I run the original sdcard_fatfs example.
Is it caused by the conflict with USB_HOST interrupt or what?
Before the function "PORT_SetPinInterruptConfig(BOARD_SDHC_CD_PORT_BASE, BOARD_SDHC_CD_GPIO_PIN, kPORT_InterruptEitherEdge);" is called, the value of user->cd changes to 0x128cc while the original working example's value is 0xa4e8. I tracked it back, the g_sd.usrParam.cd is the address of s_sdCardDetect, which is automatically generated.
Also, after entering "PORT_SetPinInterruptConfig()", the value of some variables are null while they are all 0 in the original example.
Any advice will be helpful, thanks in advance.
Hello Charles,
Hope you are doing well.
Could you please clarify the description of your application. From what I am understanding you would like the USB memory stick to work as a host. However this is not possible, a USB memory is a mass storage device.
Please let me know if I misunderstood you.
Hope it helps!
Sabina
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Sorry for the confusion, my mistake. I mean the K66 board as the host, and the memory stick works as slave. Then reading from USB memory and write to the SD card.
Hello Charles,
The examples that use host_msd are good options to get you started.
For more information on how each works please refer to the read me files located in the SDK folder using the followings paths:
SDK_2.7.0_FRDM-K66F.zip\boards\frdmk66f\usb_examples\usb_host_msd_command\freertos
SDK_2.7.0_FRDM-K66F.zip\boards\frdmk66f\usb_examples\usb_host_msd_fatfs\freertos
Please let me know if you have further questions.
Best Regards,
Sabina
Thanks, Saniba.