bootargs的mtdparts解析

Bootargs参数详解:
https://blog.csdn.net/zhangjikuan/article/details/22091335

mtdparts mtdparts=fc000000.nor_flash:1920k(linux),128k(fdt),20M(ramdisk),4M(jffs2),38272k(user),256k(env),384k(uboot)
要想这个参数起作用,内核中的mtd驱动必须要支持,
即内核配置时需要选上Device Drivers ---> Memory Technology Device (MTD) support---> Command line partition table parsing

mtdparts的格式如下:
mtdparts=[;
:= :[,]
:= [@offset][][ro]
:= unique id used in mapping driver/device
:= standard linux memsize OR "-" to denote all remaining space
:= (NAME)
因此你在使用的时候需要按照下面的格式来设置:
mtdparts=mtd-id:@(),@()

可以查看drivers/mtd/cmdlinepart.c中的注释找到相关描述。

=========================================
cmdlinepart.c和ofpart.c都将在flash驱动中被调用,一般是在probe函数中

例如jz4740_nand.c(随便找的一个nand flash的驱动)和physmap_core_of.c
的probe函数中都会调用mtd_device_parse_register函数,而该函数则通过层层调用,
最终轮询cmdlinepart.c和ofpart.c中定义的static struct mtd_part_parser结构体中的parse_fn函数,
cmdlinepart.c最终会调用parse_cmdline_partitions函数,而ofpart.c则调用parse_ofpart_partitions


mtdpart.c
定义了一个mtd_partitions链表,用于管理分区,每一个新的分区都会被添加到该链表中
static LIST_HEAD(mtd_partitions);
为分区提供读写擦除函数


mtdcore.c
mtd_device_parse_register
parse_mtd_partitions

知行合一
原文地址:https://www.cnblogs.com/grooovvve/p/14595032.html