Hi!
I'm trying to partition my eMMC memory using two partition managers.
I now have the problem that I'm only able to create the second partition on a specific place on the eMMC card. Otherwise it will timeout.
This is the relevant code snippet for partitioning.
/* Open SD-CARD driver. */
errorCode = fs_openComDrv(&pEmmcHandler,&pSdCardHandler, BSP_SDCARD_ESDHC_CHANNEL, sdCard, readOnly);
/*Open Partitionmanager. */
if(errorCode == MQX_OK)
{
errorCode = _io_part_mgr_install(pSdCardHandler,fs_PARTMAN_NAME1, 0);
errorCode = _io_part_mgr_install(pSdCardHandler,fs_PARTMAN_NAME2, 0);
}
pPartManLog = fopen(fs_PARTMAN_NAME1, NULL);
pPartManSecondary = fopen(fs_PARTMAN_NAME2, NULL);
PMGR_PART_INFO_STRUCT part_info;
uint32_t param;
/* 42 Megabyte partition. */
part_info.SLOT = 1;
part_info.TYPE = PMGR_PARTITION_FAT32;
part_info.START_SECTOR = 32;
part_info.LENGTH = 8443000 - 64;
param = 1;
errorCode = ioctl(pPartManLog, IO_IOCTL_CLEAR_PARTITION,
(uint_32_ptr) ¶m);
errorCode = ioctl(pPartManLog, IO_IOCTL_SET_PARTITION,
(uint_32_ptr) &part_info);
/* 42 Megabyte partition. */
part_info.SLOT = 2;
part_info.TYPE = PMGR_PARTITION_FAT32;
part_info.START_SECTOR = 8443000;
part_info.LENGTH = 84430;
param = 2;
errorCode = ioctl(pPartManSecondary, IO_IOCTL_CLEAR_PARTITION,
(uint_32_ptr) ¶m);
errorCode = ioctl(pPartManSecondary, IO_IOCTL_SET_PARTITION,
(uint_32_ptr) &part_info);
param = 1;
//errorCode = ioctl(pPartManLog, IO_IOCTL_VAL_PART, ¶m);
errorCode = _io_mfs_install(pPartManLog, fs_FILE_SYSTEM_NAME, param);
param = 2;
//errorCode = ioctl(pPartManLog, IO_IOCTL_VAL_PART, ¶m);
errorCode = _io_mfs_install(pPartManSecondary, fs_FILE_SYSTEM_SECONDARY, param);
pSdCardFsLogs = fopen(fs_FILE_SYSTEM_NAME, NULL);
(void)ioctl(pSdCardFsLogs, IO_IOCTL_DEFAULT_FORMAT, NULL);
pSdCardFsSecondary = fopen(fs_FILE_SYSTEM_SECONDARY, NULL); <-- This will fail if I change the start_sector.
(void)ioctl(pSdCardFsSecondary, IO_IOCTL_DEFAULT_FORMAT, NULL);
It will fail on the esdhc_read command.
/* data is word aligned, maximize speed by copying directly from the register */
while (remains >= 4)
{
if (esdhc_ptr->IRQSTAT & (SDHC_IRQSTAT_DEBE_MASK | SDHC_IRQSTAT_DCE_MASK | SDHC_IRQSTAT_DTOE_MASK))
{
esdhc_ptr->IRQSTAT |= SDHC_IRQSTAT_DEBE_MASK | SDHC_IRQSTAT_DCE_MASK | SDHC_IRQSTAT_DTOE_MASK | SDHC_IRQSTAT_BRR_MASK; <--- Fails here, the DTOE flag is set after the first byte is read.
return IO_ERROR;
}
Anyone else that have had problems using eMMC and partitioning?
Solved! Go to Solution.
The problem did not lie in the way I opened the device.
The problem was that I had initialized the device with byte addressing but it should have been addressed with block addressing method.
The SDHC driver in MQX is not returning a fault if you try to access outside the boundaries of the device, that gave me some problems when debugging, it will just stay silent and hang on that line.
Best regards
Anton Svensson
I see that you tried install partition manager twice.
I suppose that this could cause this issue.
You should install partition manager over SD card and subsequently open selected partitions. For example:
// Install partition manager over SD card driver
errorCode= _io_part_mgr_install (pSdCardHandler, "pm:", 0 );
pPartManLog = fopen ( "pm:1", NULL );
pPartManSecondary = fopen ( "pm:2", NULL );
//pm:0 is whole device; pm:1, pm:2, pm:3, pm:4 are partitions
Optionally you can use IOCTL command for selecting right partition:
// Install partition manager over SD card driver
errorCode = _io_part_mgr_install (pSdCardHandler, "pm:", 0 );
pPartManLog = fopen ( "pm:", NULL );
partition_number = 1;
error_code = ioctl(pPartManLog, IO_IOCTL_SEL_PART, &partition_number);
pPartManSecondary = fopen ( "pm:", NULL );
partition_number = 2;
error_code = ioctl(pPartManSecondary, IO_IOCTL_SEL_PART, &partition_number);
// partition_number=0 is whole device, 1, 2, 3, 4 are partitions
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
The problem did not lie in the way I opened the device.
The problem was that I had initialized the device with byte addressing but it should have been addressed with block addressing method.
The SDHC driver in MQX is not returning a fault if you try to access outside the boundaries of the device, that gave me some problems when debugging, it will just stay silent and hang on that line.
Best regards
Anton Svensson
Thank you for your notification about root cause.