static const char *part_probes[] __initdata = {"cmdlinepart", "RedBoot", NULL}; 这个说明MTD分区参数的分析有两种方法,一个是命令行,一个是通过redboot
在xxx_flash_init函数(xxx是芯片代号)中会调用np = parse_mtd_partitions(mtd, part_probes, &mtd_parts, 0);遍历两种方法。
先看命令行方式,这个命令行是定义在kernel.config中的:
CONFIG_CMDLINE="console=ttyS0,115200 root=31:2 rootfstype=squashfs init=/sbin/init mtdparts=xxx-nor0:128k(u-boot),1024k(kernel),3840k(rootfs),1984k(config),64k(art) mem=128M"
这种方式通过下面的数据结构定义:
static struct mtd_part_parser cmdline_parser = {
.owner = THIS_MODULE,
.parse_fn = parse_cmdline_partitions,
.name = "cmdlinepart",
};
这个数据结构通过name匹配方法,然后调用会掉函数parse_fn,也就是调用parse_cmdline_partitions;
static int parse_cmdline_partitions(struct mtd_info *master,
struct mtd_partition **pparts,
unsigned long origin)
解析命令行参数函数的入口是parse_cmdline_partitions,该函数中调用了mtdpart_setup_real,该函数调用了newpart,这个newpart函数就是将cmdline命令中
在xxx_flash_init函数(xxx是芯片代号)中会调用np = parse_mtd_partitions(mtd, part_probes, &mtd_parts, 0);遍历两种方法。
先看命令行方式,这个命令行是定义在kernel.config中的:
CONFIG_CMDLINE="console=ttyS0,115200 root=31:2 rootfstype=squashfs init=/sbin/init mtdparts=xxx-nor0:128k(u-boot),1024k(kernel),3840k(rootfs),1984k(config),64k(art) mem=128M"
这种方式通过下面的数据结构定义:
static struct mtd_part_parser cmdline_parser = {
.owner = THIS_MODULE,
.parse_fn = parse_cmdline_partitions,
.name = "cmdlinepart",
};
这个数据结构通过name匹配方法,然后调用会掉函数parse_fn,也就是调用parse_cmdline_partitions;
static int parse_cmdline_partitions(struct mtd_info *master,
struct mtd_partition **pparts,
unsigned long origin)
解析命令行参数函数的入口是parse_cmdline_partitions,该函数中调用了mtdpart_setup_real,该函数调用了newpart,这个newpart函数就是将cmdline命令中