Problem Creating MFS Partition MQX 4.0

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem Creating MFS Partition MQX 4.0

2,548 次查看
Teckna
Contributor V

Hi All,

I 've developed an application using CW10.2 and MQX 3.8.1.

Now i'am making the porting of all my application on MQX4.0 but i've a problem on MFS driver creating the partiton manager.


In my app on MQX3.8.1 the working procedure was:

1) Install partition manager over my device driver by "_io_part_mgr_install()" instruction

2) Open partition manager by "fopen" instruction

3)Create partition by "ioctl(handle, IO_IOCTL_SET_PARTITION, (uint_32_ptr) &part_info)" instruction

4)Install MFS over partition by  "_io_mfs_install()" instruction.

This procedure was repeated because i have more partion.


Using MQX4.0 and same procedure "ioctl(handle, IO_IOCTL_SET_PARTITION, (uint_32_ptr) &part_info)" instruction return IO_ERROR_DEVICE_BUSY error:

This is the code of  _io_part_mgr_ioctl function in MQX4.0:

        case IO_IOCTL_SET_PARTITION:

            if (part_info_ptr->SLOT)

            {

                /* Available only if operating on whole device */

                result = MQX_IO_OPERATION_NOT_AVAILABLE;

                break;

            }

            _lwsem_wait(&pm_struct_ptr->SEM);

            if (pm_struct_ptr->INSTANCES)

            {

                /* Available if this is the only instance to avoid inconsistencies */

                result = IO_ERROR_DEVICE_BUSY;

            }

            else {

                result = _pmgr_set_part_info(pm_struct_ptr, (PMGR_PART_INFO_STRUCT_PTR) param_ptr);

            }

            _lwsem_post(&pm_struct_ptr->SEM);

            break;

In MQX3.8.1 it was:

        case IO_IOCTL_SET_PARTITION:

            _lwsem_wait(&pt_mgr_ptr->SEM);

            result = _pmgr_set_part_info(pt_mgr_ptr, (PMGR_PART_INFO_STRUCT_PTR) param_ptr, 0);

            _lwsem_post(&pt_mgr_ptr->SEM);        

            break;

The problem is INSTANCES parameter (a new parameter not present in MQX3.8.1) .

This parameter is incremented in _io_part_mgr_open when i open partition manager therefore when i call ioctl its return is always IO_ERROR_DEVICE_BUSY.

Which is the way to create a partition in MQX4.0?

0 项奖励
回复
6 回复数

1,558 次查看
Teckna
Contributor V

I try to implement MFS sdcard example that represents my case but it doesn't work:

    char         filesystem_name[] = "a:";

    char         partman_name[] = "pm:";

    char         partition_name[] = "pm:1";

/* Open the device which MFS will be installed on */

sdcard_handle = fopen("sdcard:", 0);

...

/* Install partition manager over SD card driver */

error_code = _io_part_mgr_install(sdcard_handle, partman_name, 0);

..

/* Open partition */

partition_handle = fopen(partition_name, NULL);  -->return Error


By step into debug mode i see that error is generated in

int_32 _pmgr_get_part_info

    (

    PART_MGR_STRUCT_PTR        pm_struct_ptr,   /*[IN] the partition manager information */

    PMGR_PART_INFO_STRUCT_PTR  host_entry       /*[IN]/[OUT] the entry to read from disk */

    )

............

            _pmgr_disk_to_host(disk_entry + host_entry->SLOT - 1, host_entry);

            if (host_entry->TYPE == 0 || host_entry->START_SECTOR == 0 || host_entry->LENGTH == 0)

            {

               error_code = PMGR_INVALID_PARTITION;

            }

.........

}

TYPE, START_SECTOR and LENGHT parameters must be set by

ioctl(handle, IO_IOCTL_SET_PARTITION, (uint_32_ptr) &part_info)

but handle would be my partition_handle that is NULL.

Where am i wrong?

0 项奖励
回复

1,558 次查看
JerryFan
NXP Employee
NXP Employee

Hi Teckna,

The line " TYPE, START_SECTOR and LENGHT parameters must be set by ioctl(handle, IO_IOCTL_SET_PARTITION, (uint_32_ptr) &part_info)" is not ture.  Actually, the  TYPE, START_SECTOR and LENGHT and other host_entry fields are loaded from the MBR of the disk.

   read(pm_struct_ptr->DEV_FILE_PTR, mbr_ptr, size)

    ...

   disk_entry = (PMGR_PART_STURCT_PTR)(mbr_ptr + PMGR_PARTITION_TABLE_OFFSET);

   _pmgr_disk_to_host(disk_entry + host_entry->slot -1, host_entry)

   ....

It is quite likely that your SD card's MBR be corrupted. Format this card in your PC can fix this.

0 项奖励
回复

1,558 次查看
Teckna
Contributor V

Hi Chongbin,

my device isn't an SD card but it's an external dataflash where i create two partiton with different TYPE, START_SECTOR and LENGTH  defined in

PMGR_PART_INFO_STRUCT part_info;

and set by

ioctl(handle, IO_IOCTL_SET_PARTITION, (uint_32_ptr) &part_info)

Then i install MFS over each partiton

In my working project developed with MQX3.8.1 i use procedure of sdcard example and it runs!


In MQX4.0 i'm not able to use IO_IOCTL_SET_PARTITION.

There is an example that explains it?




0 项奖励
回复

1,558 次查看
Teckna
Contributor V

Any News?

0 项奖励
回复

1,558 次查看
JerryFan
NXP Employee
NXP Employee

  Again, "Actually, the  TYPE, START_SECTOR and LENGHT and other host_entry fields are loaded from the MBR of the disk", no matter on SD , nandflash or other device. Please check your device's MBR, to make sure the information within it is proper. 

0 项奖励
回复

1,558 次查看
ironsean
Contributor V

In that case, how to you set a devices MBR information when creating a new partition?

0 项奖励
回复