Now, I think my problem can be more specific.
By my understanding, the process of using MFS over SD card is like this :
(1) install ESDHC driver;
(2) get the device pointer of SD card;
(3) install MFS over SD card;
(4) use MFS;
In this order, I have write a test MQX project, the main progress is as follows. the test result is I can not open the MFS by using this "MFS_fd = fopen("a:",NULL);", also the MFS installing progress returns a successful result wihout insert a SD card. still creating a file in SD card is failed, even using "a".
I am seeking the cause of this problem desperately, please pay enough attention to my question and give me same useful tips. I am anxious of this , for this problem have delayed the progress of my project.
thank you very much.
FILE_PTR esdhc_fd,MFS_fd;
ESDHC_COMMAND_STRUCT command;
bool sdhc;
_mqx_int error_code;
uint32_t param,rca,sector;
uint8_t buffer[512];
printf("*********************************\n");
printf("******sd card test project*******\n");
printf("*********************************\n");
esdhc_fd = fopen("esdhc:",NULL);
if(NULL==esdhc_fd)
{
printf("open esdhc failed.\n");
}
else
{
printf("open esdhc successed.\n");
}
/* Initialize and detect card */
if (ESDHC_OK != ioctl (esdhc_fd, IO_IOCTL_ESDHC_INIT, NULL))
{
printf("init esdhc failed.\n");
}
else
{
printf("init esdhc successed.\n");
}
/* SDHC check */
sdhc = FALSE;
param = 0;
if (ESDHC_OK != ioctl (esdhc_fd, IO_IOCTL_ESDHC_GET_CARD, ¶m))
{
printf("find no sd card.\n");
}
if ((ESDHC_CARD_SD == param) || (ESDHC_CARD_SDHC == param) || (ESDHC_CARD_SDCOMBO ==
param) || (ESDHC_CARD_SDHCCOMBO == param))
{
if ((ESDHC_CARD_SDHC == param) || (ESDHC_CARD_SDHCCOMBO == param))
{
sdhc = TRUE;
printf("find a sd card.\n");
}
}
else
{
/* Not SD memory card */
printf("find no sd card.\n");
}
/* Install MFS over SD card driver */
error_code = _io_mfs_install(esdhc_fd, "a:", (_file_size)0);
if ((error_code != MFS_NO_ERROR)&&(error_code != MFS_NOT_A_DOS_DISK))
{
printf("Error initializing MFS: %s\n", MFS_Error_text((uint32_t)error_code));
}
else
{
printf("intalll MFS over SD card successed.\n");
}
MFS_fd = fopen("a:",NULL);
if(NULL==MFS_fd)
{
printf("open MFS failed.\n");
}
else
{
printf("open MFS successed.\n");
}
fopen("a:myfile.txt","a");