mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 09:45:55 +08:00
imx95-a55-evk: add MBR/GPT partition table parsing on eMMC
Parse the partition table on /dev/mmcsd0 during board bringup and register each partition as /dev/mmcsd0pN. MBR partitions have no name field so a custom handler is needed instead of the default register_partition which skips unnamed entries. Verify by i.mx95 FRDM 'mount -t vfat /dev/mmcsd0p0 /data' Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
@@ -27,14 +27,31 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/partition.h>
|
||||
|
||||
#include "imx9_dma_alloc.h"
|
||||
|
||||
#include "imx95-evk.h"
|
||||
|
||||
#if defined(CONFIG_GPT_PARTITION) || defined(CONFIG_MBR_PARTITION)
|
||||
static void mmcsd_partition_handler(FAR struct partition_s *part,
|
||||
FAR void *arg)
|
||||
{
|
||||
char devname[32];
|
||||
|
||||
snprintf(devname, sizeof(devname), "/dev/mmcsd0p%zu", part->index);
|
||||
register_blockpartition(devname, 0660, "/dev/mmcsd0",
|
||||
part->firstblock, part->nblocks);
|
||||
syslog(LOG_INFO, "Registered partition %s (start=%lu nblocks=%lu)\n",
|
||||
devname, (unsigned long)part->firstblock,
|
||||
(unsigned long)part->nblocks);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -78,6 +95,18 @@ int imx9_bringup(void)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to init MMCSD driver: %d\n", ret);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_GPT_PARTITION) || defined(CONFIG_MBR_PARTITION)
|
||||
else
|
||||
{
|
||||
ret = parse_block_partition("/dev/mmcsd0",
|
||||
mmcsd_partition_handler, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to parse partition table: %d\n", ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
|
||||
Reference in New Issue
Block a user