nandflash分区
系统的NAND FLASH分区依赖于u-boot和Linux内核两方面的设置。
1. uboot中主要配置uboot和params占用空间
文件:include/configs/开发板.h
这是Phy3250的参数,Phy3250采用32MB的NAND FLASH,扇区大小为16KB:
189 /* Phy3250's NAND FLASH, 32MB, 16K size(Block, Sector) */ 190 //#define CFG_ENV_SIZE 0x4000 /* 1 block, 16K */ 191 //#define CFG_ENV_OFFSET 0x168000 /* Block 90 */
如下是SmartARM3250的NAND FLASH,K9F2G08,256MB,扇区大小为128K:
193 /* SmartARM3250's NAND FLASH, K9F2G08, 256MB, 128K size(Block, Sector) */ 194 #define CFG_ENV_SIZE 0x40000 /* 2 Block, 256K */ 195 #define CFG_ENV_OFFSET 0x180000 /* Block 12 */
2. 内核中通过板级文件指定
nandflash分区位置和大小是由内核的板级支持包中指定的。
在linux-2.6.27.8/arch/arm/mach-lpc32xx/board-smartarm3250.c中的实现代码:
153 #define BLK_SIZE (0x20000) //128KB 154 static struct mtd_partition __initdata smartarm3250_nand_partition[] = { 155 { 156 .name = "smartarm3250-boot", 157 .offset = 0, 158 .size = (BLK_SIZE * 12) 159 }, 160 { 161 .name = "smartarm3250-ubt-prms", 162 .offset = (BLK_SIZE * 12), 163 .size = (BLK_SIZE * 2) 164 }, 165 { 166 .name = "smartarm3250-kernel", 167 .offset = (BLK_SIZE * 16), 168 .size = (BLK_SIZE * 32) 169 }, 170 { 171 .name = "smartarm3250-rootfs", 172 .offset = (BLK_SIZE * 48), 173 .size = MTDPART_SIZ_FULL 174 }, 175 };
3. uboot通过bootargs传参给内核,从而内核找到文件系统挂载
一个nandflash的bootargs参考:
set bootargs noinitrd console=ttySAC0 root=/dev/mtdblock3 rootfstype=jffs2 mtdparts=nand_flash:128k(u-boot)ro,64k(u-boot envs),3m(kernel),30m(root.jffs2),30m(root.yaffs)
参考: