AnsweredAssumed Answered

ramdisk failure

Question asked by KRISTIE SIRCLUM on Apr 27, 2015
Latest reply on Apr 30, 2015 by David E Seymour

Hi,

using MQX4.0.2 on K60FX512, I want to create small ramdisk, but always get error MFS_WRITE_FAULT  during format, what is wrong?

 

extern unsigned char  extBuffer[4096];

MQX_FILE_PTR a_fd_ptr;

void Ram_disk_start(void)

{

   MQX_FILE_PTR               dev_handle1,fp;

   int_32                     error_code;

   _mqx_uint                  mqx_status;

   a_fd_ptr = 0;

   mqx_status = _io_mem_install("mfs_ramdisk:", (uchar_ptr)&extBuffer[0],   (_file_size)4096);

   dev_handle1 = fopen("mfs_ramdisk:", "b");

   mqx_status = _io_mfs_install(dev_handle1, "b:", 0);

 

   a_fd_ptr = fopen("b:", NULL);

   error_code    = ferror(a_fd_ptr);

   if ( error_code == MFS_NOT_A_DOS_DISK ) {

      printf("\nNOT A DOS DISK! You must format to continue.");

      rdformat();

   }

 

   

}

void rdformat(void)

{

       int_32                     error_code = IO_ERROR;      

       uint_32 bad_cluster_count;

 

       MFS_IOCTL_FORMAT_PARAM format_struct;

       MFS_FORMAT_DATA MFS_format =

       {

       /* PHYSICAL_DRIVE; */ 0x80,

       /* MEDIA_DESCRIPTOR; */ 0xf8,

       /* BYTES_PER_SECTOR; */ 256,

       /* SECTORS_PER_TRACK; */ 0,

       /* NUMBER_OF_HEADS; */ 0,

       /* NUMBER_OF_SECTORS; */ 16, /* depends on disk */

       /* HIDDEN_SECTORS; */ 0,

       /* RESERVED_SECTORS; */ 0

       };

       format_struct.FORMAT_PTR = &MFS_format;

       format_struct.COUNT_PTR = &bad_cluster_count;

 

 

    error_code = ioctl(a_fd_ptr, IO_IOCTL_FORMAT,  (uint_32_ptr) &format_struct);

    if (error_code) {

       printf("Error while formatting: 0x%x\n", error_code);

    }

}   

Outcomes