AnsweredAssumed Answered

problems with ESDHC driver and MFS

Question asked by botao yang on Apr 21, 2015
Latest reply on Jan 6, 2016 by thiagow

I want to use MFS on SD card, and I built a MQX project, but I can creat a flie or read a file in SD card, the main prosses in as below:

 

  

com_handle = fopen("esdhc:", 0);

 

if (NULL == com_handle)
{
    printf("Error opening communication handle %s, check your user_config.h.\n");//, SDCARD_COM_CHANNEL);
    _task_block();
}
else
{
   printf("success opening communication handle.\n");
}

   

 

/* Install SD card device */
error_code = _io_sdcard_install("sdcard:", (pointer)&_bsp_sdcard0_init, com_handle);
if ( error_code != MQX_OK )
{
    printf("Error installing SD card device (0x%x)\n", error_code);
    _task_block();
}
else
{
   printf("success installing SD card device.\n");
}

 

 

/* Open the device which MFS will be installed on */
sdcard_handle = fopen("sdcard:", 0);
if (sdcard_handle == NULL)
{
    printf("Unable to open SD card device.\n");
           // continue;
}
else
{
    printf("success to open SD card device.\n");
}
  

   

error_code = _io_mfs_install(sdcard_handle, filesystem_name, 0);
if (error_code != MFS_NO_ERROR)
{
    printf("Error initializing MFS over partition: %s\n", MFS_Error_text((uint_32)error_code));
}
else
{
    printf("success initializing MFS.\n");
}   

   

char buffer1[100] = "111111111111.\n" ;
char buffer2[100];
uint32_t i;

   

mfs_fd_ptr = fopen(filesystem_name,NULL);
if (mfs_fd_ptr == NULL)
{
    printf("Error opening MFS device driver. %s\n");
}
else
{
    printf("success opening MFS device driver.\n");
}   

   

//error_code = ioctl(mfs_fd_ptr,IO_IOCTL_DELETE_FILE,"myfile.txt");

   

fd_ptr = fopen("a:myfile.txt","a+");
write(fd_ptr,buffer1,strlen(buffer1));
read(fd_ptr,buffer2,strlen(buffer1));

 

   

    the return message is all correct, but I can open myflie.txt correctly.

    I want to know what is the problem and how to solve it, thank you !

Outcomes