由於BOOTLOADRER、PARAMS以及核心、檔案系統都在NAND FLASH上,因此分區就得進行統一規劃。系統的NAND FLASH分區依賴於u-boot和Linux核心兩方面的設定。 U-Boot中的NAND分區 檔案: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 */ Kernel中的NAND FLASH分區 NAND FLASH規劃 分 區 位址範圍 扇區範圍 大 小 用 途 Bootloader 0x0000 0000 ~ 0x0018 0000 0 ~ 11 12個扇區,1.50M S1L和U-Boot param 0x0018 0000 ~ 0x001C 0000 12~13 2個扇區, 256K U-Boot參數 保留 0x001C 0000 ~ 0x0020 0000 14~15 Linux Kernel 0x0020 0000 ~ 0x0060 0000 16~47 32個扇區,4.00M Linux核心 Rootfs 0x0060 0000 ~ 0x1000 0000 48~2047 2000個扇區,250M Linux檔案系統
| rootfs |
2047 48 |
共2000扇區 |
| Kernel |
47 16 |
共32扇區 |
| 保留 |
15 14 |
共2扇區 |
| param |
13 12 |
共2扇區 |
| Bootlloader |
11 0 |
共12扇區 |
分區實現在linux-2.6.27.8/arch/arm/mach-lpc32xx/board-smartarm3250.c中的實現代碼:153 #define BLK_SIZE (0x20000) //128KB154 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_FULL174 },175 };