NorFlash linux分区分析

一般情况下,与板卡相关的内容都在bsp中(即arch/arm/mach-xxx/board-xxx.c)中,但norflash的分区直接放在norflash驱动中。由于norflash应用基于mtd,所以驱动位于drivers/mtd/目录下,chips目录是norflash相关公用驱动,maps是不同板卡应用的的驱动,如at91sam9261.c。分区信息便在板卡norflash驱动文件中。

#define WINDOW_ADDR 0x10000000      /* physical properties of flash */

#define WINDOW_SIZE 0x800000

#define BUSWIDTH    2

 

#define MSG_PREFIX "SAM9261-NOR:"   /* prefix for our printk()'s */

#define MTDID      "sam9261-nor"    /* for mtdparts= partitioning */

 

static struct mtd_info *mymtd;

 

struct map_info sam9261nor_map = {

    .name = "NOR flash on sam9261",

    .size = WINDOW_SIZE,

    .bankwidth = BUSWIDTH,

    .phys = WINDOW_ADDR,

};

 

#ifdef CONFIG_MTD_PARTITIONS

 

/*

 * MTD partitioning stuff

 */

static struct mtd_partition sam9261_partitions[] =

{

#if 1           /* New fs */

    {   /* rootfs 2M */

        .name = "rootfs",

        .size = MTDPART_SIZ_FULL,

        .offset = 0x380000,

    },

#endif

};

驱动定义两个函数,用于加载卸载驱动:

static int __init init_sam9261nor(void);

static void __exit cleanup_sam9261nor(void);

module_init(init_sam9261nor);

module_exit(cleanup_sam9261nor);

 

posted @ 2016-10-09 20:39  yuxi_o  阅读(1795)  评论(0编辑  收藏  举报