Hi folks,
I have run up in to a problem of MFS giving me error MFS_NOT_A_DOS_DISK.
Since all the function calls like - io_usb_mfs_install, io_mfs_install, fopen return MQX_OK(no error), I cant find the source of code that changes ERROR element of FS_FS_PTR sturcture.
Please help me find out. The code is attached with this post.
Thank you for your time.
Regards,
Nitin
Original Attachment has been moved to: mfs_install.c.zip
According with the Freescale MQX RTOS MFS User’s Guide:
_io_mfs_install
Install MFS.
Synopsis
uint32_t _io_mfs_install(
/*[IN] the device on which to install MFS */
FILE_PTR dev_fd,
/*[IN] Name to be given to MFS (e.g. "C:", "MFS1:") */
/* The name must end in a colon ":" */
char * identifier,
/*[IN] Partition number to install MFS on. */
/* 0 for no partitions */
uint32_t partition_num)
Description
The function initializes MFS and allocates memory for all of the internal MFS data structures. It also reads some required drive information from the disk, on which it is installed. MFS supports FAT12, FAT16, and FAT32 file systems. If the disk has a different file system or if it is unformatted, you can use MFS to format it to one of the supported file systems.
If the application uses a partitioned disk, you must install MFS on a partition manager device driver. The partition manager device driver can create partitions on the disk if there are none. It can also remove partitions.
Usage of partition_num parameter is deprecated - _io_mfs_install should obtain handle to partition manager associated with particular partition as dev_fd. partition_num parameter should be set to 0 which instructs MFS to simply use the dev_fd as underlying device.
Return Codes
Returns a uint32_t error code.
• IO_EOF
— The FILE_PTR passed into _io_mfs_install() was NULL. The error is returned by the input/output subsystem of the MQX Real-Time Operating System.
• MFS_ERROR_UNKNOWN_FS_VERSION
— MFS was installed on a disk using the FAT32 file system, and the FAT32 version is incompatible with the MFS FAT32 version (version zero).
• MFS_INSUFFICIENT_MEMORY
— MFS could not allocate memory for required structures.
• MFS_NO_ERROR
— The function call was successful.
• MFS_NOT_A_DOS_DISK
— The device, on which MFS is being installed is not a valid DOS device. The device must be formatted (by an input/output control command).
• MFS_NOT_INITIALIZED
— The MFS device name did not end with colon (:).
• MFS_READ_FAULT
— The lower-level device driver could not read from the disk. The error is returned from the device, over which MFS is installed.
• MFS_SECTOR_NOT_FOUND
— The error is returned from the device, over which, MFS is installed.
• PGMR_INVALID_PARTITION
— The partition number specified was that of an invalid partition. The partition does not exist.
Example
Install MFS on a RAM disk with no partitions.
/* Install the memory device: */
error_code = _io_mem_install("mfsram:",
NULL, MFS_format.BYTES_PER_SECTOR * RAMDISK_LENGTH1);
if ( error_code != MQX_OK ) {
printf("Error installing device.\nError: %d\n", error_code);
_mqx_exit(1);
}
/* Open the device on which MFS will be installed: */
dev_handle1 = fopen("mfsram:", 0);
if ( dev_handle1 == NULL ) {
printf("\nUnable to open RAM disk device");
_task_block();
}
/* Install MFS: */
error_code = _io_mfs_install(dev_handle1, "MFS1:", 0);
if ((error_code != MFS_NO_ERROR) &&
(error_code != MFS_NOT_A_DOS_DISK)) {
printf("FATAL error while initializing: \n");
_mqx_exit(1);
} else {
printf("Initialized MFS1%s\n");
}
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------