Linux Command Line - mtdparts

Posted 9:33 PM by 陳俞安 in Labels: ,
Device Drivers --->
     Memory Technology Device (MTD) support --->
          [*] MTD partitioning support
          [*] Command line partition table parsing

linux command mtdparts 格式:
mtdparts   = <mtddef>[;<mtddef ]
<mtddef>  := <mtd-id>:<partdef>[,<partdef>]
<partdef> := <size>[@offset][<name>][ro]
<mtd-id>  := unique id used in mapping driver/device
<size>      := standard linux memsize OR "-" to denote all
remaining space
<name>    := (NAME)


但是 s3c2410.c 並沒有把 linux command mtdparts 實做出來。
難怪怎麼測試都沒反應。

修改 linux/driver/mtd/nand/s3c2410.c:

#ifdef CONFIG_MTD_PARTITIONS

#ifdef CONFIG_MTD_CMDLINE_PARTS 
const char *part_probes[] = { "cmdlinepart", NULL };
#endif


static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
                                      struct s3c2410_nand_mtd *mtd,
                                      struct s3c2410_nand_set *set)
{
#ifdef CONFIG_MTD_CMDLINE_PARTS 
        struct mtd_partition *partitions = NULL;
        int num_partitions = 0;
#endif
        if (set == NULL)
                return add_mtd_device(&mtd->mtd);

#ifdef CONFIG_MTD_CMDLINE_PARTS
        mtd->mtd.name = "s3c2440_nand";
        num_partitions = parse_mtd_partitions(&(mtd->mtd), part_probes, &partitions, 0);

        if(num_partitions > 0) {
            set->partitions = partitions;
            set->nr_partitions = num_partitions;
        }
#endif

        if (set->nr_partitions > 0 && set->partitions != NULL) {
             return add_mtd_partitions(&mtd->mtd, set->partitions, set->nr_partitions);
        } 
        return add_mtd_device(&mtd->mtd);
}

#else
........ }


這樣就可以在 linux command line 裡面把分區傳給 kernel
使用方法
mtdparts=s3c2440_nand:<size1>@<offset1>(<name1>),<size2>@<offset2>(<name2>)

其中 "s3c2440_nand" 要跟 mtd->mtd.name 一樣



0 comment(s) to... “Linux Command Line - mtdparts”

0 comments: