Ralink 5350 flash大小选择和添加mtd的data分区

需要修改位置:

(1)/Linux-2.6/arch/mips/rt2880/Kconfig
(2)/linux-2.6/drivers/mtd/maps/ralink-flash.h
(3)/linux-2.6/drivers/mtd/maps/ralink-spi.c
(4)/vendors/Ralink/RT5350/config/4M_32M_config.linux-2.6(make dep 后生成的config.h)

一)添加menuconfig中选项

choice  
    prompt "Flash Size"  
    default RT2880_FLASH_4M  
      
config T2880_FLASH_2M  
        bool "2M"  
  
config RT2880_FLASH_4M  
        bool "4M"  
  
config RT2880_FLASH_8M  
        bool "8M"  
  
config RT2880_FLASH_16M  
        bool "16M"  
      
config RT2880_FLASH_32M  
        bool "32M"  
#   select RT2880_FLASH_32M  
endchoice  
  
#Data分区 #注释部分不无效  
choice  
    prompt "Flash Data Size"  
    default RT2880_FLASH_DATA_320KB  
  
config RT2880_FLASH_DATA_0KB  
        bool "none(0)KB"  
          
#config RT2880_FLASH_DATA_64KB  
#        bool "0x10000(64)KB"  
          
#config RT2880_FLASH_DATA_128KB  
#        bool "0x20000(128)KB"  
          
#config RT2880_FLASH_DATA_192KB  
#        bool "0x30000(192)KB"  
          
#config RT2880_FLASH_DATA_256KB  
#        bool "0x40000(256)KB"  
          
config RT2880_FLASH_DATA_320KB  
        bool "0x50000(320)KB"  
  
config RT2880_FLASH_DATA_384KB  
        bool "0x60000(384)KB"  
  
endchoice     
  
config MTD_PHYSMAP_DATA_LEN  
       hex   
       default 0x0 if RT2880_FLASH_DATA_0KB  
       default 0x10000 if RT2880_FLASH_DATA_64KB  
       default 0x20000 if RT2880_FLASH_DATA_128KB  
       default 0x30000 if RT2880_FLASH_DATA_192KB  
       default 0x40000 if RT2880_FLASH_DATA_256KB  
       default 0x50000 if RT2880_FLASH_DATA_320KB  
       default 0x60000 if RT2880_FLASH_DATA_384KB  
  
choice  

二)添加data分区大小,修改kernel分区大小。

#if defined (CONFIG_RT2880_FLASH_32M)
#define MTD_BOOT_PART_SIZE	0x40000
#define	MTD_CONFIG_PART_SIZE	0x20000
#define	MTD_FACTORY_PART_SIZE	0x20000
#define MTD_DATA_PAPT_SIZE  CONFIG_MTD_PHYSMAP_DATA_LEN/**/
#else
#if defined (RECONFIG_PARTITION_SIZE)
#if !defined (MTD_BOOT_PART_SIZE)
#error "Please define MTD_BOOT_PART_SIZE"
#endif
#if !defined (MTD_CONFIG_PART_SIZE)
#error "Please define MTD_CONFIG_PART_SIZE"
#endif
#if !defined (MTD_FACTORY_PART_SIZE)
#error "Please define MTD_FACTORY_PART_SIZE"
#endif
#else
#define MTD_BOOT_PART_SIZE	0x30000
#define	MTD_CONFIG_PART_SIZE	0x10000
#define	MTD_FACTORY_PART_SIZE	0x10000
#define MTD_DATA_PAPT_SIZE  CONFIG_MTD_PHYSMAP_DATA_LEN<span style="font-family: Arial, Helvetica, sans-serif;">/*添加data分区长度*/</span>
#endif
#endif




#ifdef CONFIG_RT2880_ROOTFS_IN_FLASH
#ifdef CONFIG_ROOTFS_IN_FLASH_NO_PADDING
#define CONFIG_MTD_KERNEL_PART_SIZ 0
#endif
#define MTD_ROOTFS_PART_SIZE	IMAGE1_SIZE - (MTD_BOOT_PART_SIZE + MTD_CONFIG_PART_SIZE \
					+ MTD_FACTORY_PART_SIZE + CONFIG_MTD_KERNEL_PART_SIZ  + MTD_DATA_PAPT_SIZE)
#define	MTD_KERN_PART_SIZE	CONFIG_MTD_KERNEL_PART_SIZ
//#define	MTD_KERN_PART_SIZE	0x310000
#else //CONFIG_RT2880_ROOTFS_IN_ROM
#define MTD_KERN_PART_SIZE	IMAGE1_SIZE - (MTD_BOOT_PART_SIZE + MTD_CONFIG_PART_SIZE \
					+ MTD_FACTORY_PART_SIZE + MTD_DATA_PAPT_SIZE)/*计算除去data分区长度后内存分区长度*/
//#define	MTD_KERN_PART_SIZE	0x310000
#endif

三)定义data分区

static struct mtd_partition rt2880_partitions[] = {
	{
                name:           "ALL",
                size:           MTDPART_SIZ_FULL,
                offset:         0,
        },
	/* Put your own partition definitions here */
        {
                name:           "Bootloader",
                size:           MTD_BOOT_PART_SIZE,
                offset:         0,
        }, {
                name:           "Config",
                size:           MTD_CONFIG_PART_SIZE,
                offset:         MTDPART_OFS_APPEND
        }, {
                name:           "Factory",
                size:           MTD_FACTORY_PART_SIZE,
                offset:         MTDPART_OFS_APPEND
#ifdef CONFIG_RT2880_ROOTFS_IN_FLASH
        }, {
                name:           "Kernel",
                size:           MTD_KERN_PART_SIZE,
                offset:         MTDPART_OFS_APPEND,
        }, {
                name:           "RootFS",
                size:           MTD_ROOTFS_PART_SIZE,
                offset:         MTDPART_OFS_APPEND,
    #ifdef CONFIG_ROOTFS_IN_FLASH_NO_PADDING
        }, {
                name:           "Kernel_RootFS",
                size:           MTD_KERN_PART_SIZE + MTD_ROOTFS_PART_SIZE,
                offset:         MTD_BOOT_PART_SIZE + MTD_CONFIG_PART_SIZE + MTD_FACTORY_PART_SIZE,
    #endif
#else //CONFIG_RT2880_ROOTFS_IN_RAM
        }, {
                name:           "Kernel",
                size:           MTD_KERN_PART_SIZE,
                offset:         MTDPART_OFS_APPEND,
#endif//CONFIG_RT2880_ROOTFS_IN_FLASH

#ifdef CONFIG_DUAL_IMAGE
        }, {
                name:           "Kernel2",
                size:           MTD_KERN2_PART_SIZE,
                offset:         MTD_KERN2_PART_OFFSET,
    #ifdef CONFIG_RT2880_ROOTFS_IN_FLASH
        }, {
                name:           "RootFS2",
                size:           MTD_ROOTFS2_PART_SIZE,
                offset:         MTD_ROOTFS2_PART_OFFSET,
    #endif
#endif//CONFIG_DUAL_IMAGE
/*DATA分区添加部分*/
		}, {
			name:		"Date", /* mtdblock5 */
			size:		MTD_DATA_PAPT_SIZE, 
			offset: 	MTDPART_OFS_APPEND,/*偏移量,data开头位置*/
        }
};


本文章由作者:佐须之男 整理编辑,原文地址: Ralink 5350 flash大小选择和添加mtd的data分区
本站的文章和资源来自互联网或者站长的原创,按照 CC BY -NC -SA 3.0 CN协议发布和共享,转载或引用本站文章应遵循相同协议。如果有侵犯版权的资 源请尽快联系站长,我们会在24h内删除有争议的资源。欢迎大家多多交流,期待共同学习进步。

相关推荐