mfs error: NOT_A_DOS_DISK

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mfs error: NOT_A_DOS_DISK

Jump to solution
1,572 Views
mfserror_NOT_A_
Contributor I

i am using mqx3.6.2 and mcf52259.

 

after install mfs on ramdisk by call _io_mfs_install(), i open it by fopen().

after fopen("a:",NULL), there is a error : "NOT_A_DOS_DISK".

 

why dos it occur this error? and how to deal with it?

 

Best Regads,

 

Labels (1)
Tags (1)
0 Kudos
1 Solution
1,003 Views
PetrM
Senior Contributor I

Hello,

 

the NUMBER_OF_SECTORS is too small. For this case it should be at least 7. But you should definitely set more to be able to store some data on the disk.

When you look at the file mfs_format.c, function MFS_Format(), you'll see that it tries to format the disk as FAT12 filesystem based on NUMBER_OF_SECTORS count and later it fails because there's not enough sectors for reserved sectors and root directory entries.

 

Regards,

PetrM

 

View solution in original post

0 Kudos
8 Replies
1,003 Views
Kafre
Contributor III

I think that you need to format the disk. See the MFS manual for further details.

0 Kudos
1,003 Views
mfserror_NOT_A_
Contributor I

Dear Kafre,

 

yes, i see the manual and call a API but the problem is not soled.

 

would you like to give me a example that how to use the API to format ?

 

Best Regards

0 Kudos
1,003 Views
PetrM
Senior Contributor I

Hello,

 

it's basically this function:

 

error_code = ioctl(mfs_handle, IO_IOCTL_DEFAULT_FORMAT,  NULL);

Check sh_format.c in Shell sources or digitalsign.c in digitalsign Demo directory for example usage.

But maybe you have problem with partitions or filesystem itself.

 

Regards,

PetrM

 

0 Kudos
1,003 Views
mfserror_NOT_A_
Contributor I

Dear PetrM,

 i try to use IO_IOCTL_FORMAT_TEST to format it , but there is a error.

the error_code is 12375 and reports FS_INVALID_PARAMETERS.

 

would you like to tell me which parameter is not correct?

 

below are my parameters:

i f ( error_code == MFS_NOT_A_DOS_DISK )
{
// printf("NOT A DOS DISK! You must format to continue.\n");
format_data.PHYSICAL_DRIVE = 0x80;
format_data.MEDIA_DESCRIPTOR = 0xf8;
format_data.BYTES_PER_SECTOR = 512;
format_data.SECTORS_PER_TRACK = 0;
format_data.NUMBER_OF_HEADS = 0;
format_data.NUMBER_OF_SECTORS = 2;
format_data.HIDDEN_SECTORS = 0;
format_data.RESERVED_SECTORS = 0;

format_struct.FORMAT_PTR = &format_data;
format_struct.COUNT_PTR = &bad_cluster_count;

error_code=ioctl(filesystem_handle, IO_IOCTL_FORMAT_TEST ,(uint_32_ptr)&format_struct);

 

Best Regards

0 Kudos
1,004 Views
PetrM
Senior Contributor I

Hello,

 

the NUMBER_OF_SECTORS is too small. For this case it should be at least 7. But you should definitely set more to be able to store some data on the disk.

When you look at the file mfs_format.c, function MFS_Format(), you'll see that it tries to format the disk as FAT12 filesystem based on NUMBER_OF_SECTORS count and later it fails because there's not enough sectors for reserved sectors and root directory entries.

 

Regards,

PetrM

 

0 Kudos
1,003 Views
mfserror_NOT_A_
Contributor I

Dear  PetrM,

 

please look at my c lines:

 

   if ( error_code == MFS_NOT_A_DOS_DISK )
   {
     //printf("NOT A DOS DISK! You must format to continue.\n");
   format_data.PHYSICAL_DRIVE    = 0x80;
   format_data.MEDIA_DESCRIPTOR  = 0xf8;
   format_data.BYTES_PER_SECTOR  = 512;
   format_data.SECTORS_PER_TRACK = 0;
   format_data.NUMBER_OF_HEADS   = 0;
   format_data.NUMBER_OF_SECTORS = 128; //at least 7
   format_data.HIDDEN_SECTORS    = 0;
   format_data.RESERVED_SECTORS  = 1;
   
   format_struct.FORMAT_PTR      = &format_data;
   format_struct.COUNT_PTR       = &bad_cluster_count;
   
   error_code=ioctl(filesystem_handle, IO_IOCTL_FORMAT_TEST ,(uint_32_ptr)&format_struct);
               
  }  
   
  if(error_code == MFS_NO_ERROR)
  {
   textfile_ptr = fopen("c:myfile.txt", "a+");   
    write(textfile_ptr, buffer, strlen(buffer));
    fclose(textfile_ptr);

    my_mfs_ptr = fopen("c:myfile.txt", "r");
    read(my_mfs_ptr, buffer1,strlen(buffer));  
    fclose(my_mfs_ptr); 
  }

 

 the format procedure will be run successfully without  the  "textfile_ptr=fopen("c:myfile.txt", "a++"); " lines.

if i cancel these lines such as below, the format runs correct.

/*

if(error_code == MFS_NO_ERROR)
  {
   textfile_ptr = fopen("c:myfile.txt", "a+");   
    write(textfile_ptr, buffer, strlen(buffer));
    fclose(textfile_ptr);

    my_mfs_ptr = fopen("c:myfile.txt", "r");
    read(my_mfs_ptr, buffer1,strlen(buffer));  
    fclose(my_mfs_ptr); 
  }

*/

 

after format successfully, i add the lines canceles before.

this time , all lines works well.

 

would you like to tell me how to use write() or read() to write/read a file after FORMAT?

 

Best regards

 

0 Kudos
1,003 Views
PetrM
Senior Contributor I

Hello,

 

maybe it depends on current directory. Try to use absolute paths - with backslash at the beginning (c:\myfile.txt).

And maybe the format_test fails. Did you check it's return code?

 

Regards,

PetrM

 

1,003 Views
mfserror_NOT_A_
Contributor I

Dear PetrM,

 

Thanks for your help.

 

Best Regards

0 Kudos