涉及源碼檔案:drivers/mtd/maps/alchemy-flash.c
10: #include <linux/config.h>
註解: 在 include/linux/config.h中,只有一句 #include <linux/autoconf.h>, 而在 include/linux/autoconf.h 中則有如下
59: #undef CONFIG_MIPS_PB1000
60: #undef CONFIG_MIPS_PB1100
61: #undef CONFIG_MIPS_PB1500
62: #undef CONFIG_MIPS_PB1550
63: #undef CONFIG_MIPS_PB1200
64: #undef CONFIG_MIPS_DB1000
65: #undef CONFIG_MIPS_DB1100
66: #undef CONFIG_MIPS_DB1500
67: #undef CONFIG_MIPS_DB1550
68:
#define CONFIG_MIPS_DB1200 1
因此對應於alchemy-flash.c 的82行定義成立
#ifdef CONFIG_MIPS_DB1200
#define BOARD_MAP_NAME "Db1200 Flash"
#define BOARD_FLASH_SIZE 0x00800000 /* 8MB */
#define BOARD_FLASH_WIDTH 2 /* 16-bits */
#endif
其中
BOARD_FLASH_SIZE
表示嵌入式系統中使用的NorFlash的容量大小,
BOARD_FLASH_WIDTH
表示NorFlash資料匯流排寬度(以byte為單位)。
在 include/linux/mtd/partitions.h中定義結構體
struct mtd_partition {
char *name; /* identifier string */
u_int32_t size; /* partition size */
u_int32_t offset; /* offset within the master MTD space */
u_int32_t mask_flags; /* master MTD flags to mask out for this partition */
struct nand_oobinfo *oobsel; /* out of band layout for this partition (NAND only)*/
struct mtd_info **mtdp; /* pointer to store the MTD object */
};
alchemy-flash.c
的
113行開始的定義則對應於NorFlash中的資料分割配置:
static struct mtd_partition alchemy_partitions[] = {
{
.name = "User FS",
.size = BOARD_FLASH_SIZE - 0x00400000, ——此處即使用宏
BOARD_FLASH_SIZE
.offset = 0x0000000
},
{
.name = "YAMON",
.size = 0x0100000,
.offset = MTDPART_OFS_APPEND,
// .mask_flags = MTD_WRITEABLE
——此處使用的宏
MTD_WRITEABLE
表示 本mtd分區起始位移量緊跟上一分區結束位置
},
{
.name = "raw kernel",
.size = (0x300000 - 0x40000), /* last 256KB is yamon env */
.offset = MTDPART_OFS_APPEND,
}
};
在這個NorFlash分區的方案中,YAMON 開始於 NorFlash的最後 4MB 起始處,整個kernel 和 Yamon佔據
NorFlash最後 4MB 空間,這可從"User FS" .size=
BOARD_FLASH_SIZE - 0x00400000 看出
因此,當NorFlash類型更換之後,需要根據新NorFlash的容量、資料寬度相應的修改
alchemy-flash.c 82行開始的宏定義
BOARD_FLASH_SIZE
和
BOARD_FLASH_WIDTH