本文开发环境为:uClinux-2.6,BF561,编译器为VDSP4.5
1 norflash: Am29LV320MT
AM29LV320MT是一个4M,16位的NorFlash,支持CFI接口,其地址空间为0x2000 0000 ~ 0x2040 0000。
1、配置异步存储器,以下是几个相关的宏:
- #define CONFIG_C_AMBEN_ALL 1
- #define CONFIG_C_B0PEN 1
- #define CONFIG_C_B1PEN 1
- #define CONFIG_C_B2PEN 1
- #define CONFIG_C_B3PEN 1
- #define CONFIG_BANK_0 0x7BB0
- #define CONFIG_BANK_1 0xFFC2
- #define CONFIG_BANK_2 0xFFC2
- #define CONFIG_BANK_3 0xFFC2
2、定义命令集:
- #define CONFIG_MTD_CFI_AMDSTD 1
3、定义Flash的基本参数:
- #define CONFIG_EBIU_FLASH_BASE 0x20000000
- #define CONFIG_BFIN_FLASH_SIZE 4
4、加入drivers/mtd/maps/ezkit561.c。
5、修改
- #define EZKIT561_FLASH_BASE 0x20000000
- #define EZKIT561_FLASH_SIZE 0x00400000
为板载Flash的地址和大小。
6、修改ezkit561_parts分区定义为希望的值。
搞定。
2 Nand:K9W8G08U1M
K9W8G08U1M是一个1G的Nand flash,由两片512M的芯片堆叠而成。其RB1与RB2接到PF4和PF5,CE1与CE2接到PF0和PF1,ALE接到PF2,CLE接到PF3。
uClinux下的驱动与u-boot下的驱动相似但略有不同。
1、加入drivers/mtd/nand/bfin_nand.c。
2、修改地址定义:
- #define BFIN_NAND_BASE 0x29000000/*CONFIG_BFIN_NAND_BASE*/
3、修改bfin_nand_init函数中设置PF口的代码:
-
- *pFIO0_DIR |= 0x000F;
- asm("ssync;");
- *pFIO0_INEN |= 0x0030;
- asm("ssync;");
4、修改以下3个控制函数:
- static void bfin_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
- {
- register struct nand_chip *this = mtd->priv;
- if (cmd == NAND_CMD_NONE)
- return;
-
- if(ctrl & NAND_CLE) {
- *pFIO0_FLAG_S = 0x04;
- *pFIO0_FLAG_C = 0x08;
- }
-
- if(ctrl & NAND_ALE) {
- *pFIO0_FLAG_C = 0x04;
- *pFIO0_FLAG_S = 0x08;
- }
-
- this->IO_ADDR_R = this->IO_ADDR_W;
-
-
- asm("ssync;");
-
-
- writeb(cmd, p_nand);
-
- asm("ssync;");
- *pFIO0_FLAG_C = 0x04 | 0x08;
-
-
-
-
-
-
-
-
-
-
-
-
- }
-
- int bfin_device_ready(struct mtd_info *mtd)
- {
- return ((*pFIO0_FLAG_D & 0x30) == 0x30) ? 1 : 0;
-
- }
-
-
-
-
-
-
-
-
- static int current_chip = -1;
- static void bfin_select_chip(struct mtd_info *mtd, int chip)
- {
- struct nand_chip *this = mtd->priv;
- current_chip = chip;
- switch(chip) {
- case -1:
- *pFIO0_FLAG_S = 0x03;
- break;
- case 0:
- *pFIO0_FLAG_C = 0x01;
- asm("ssync;");
- *pFIO0_FLAG_S = 0x02;
- break;
- case 1:
- *pFIO0_FLAG_C = 0x02;
- asm("ssync;");
- *pFIO0_FLAG_S = 0x01;
- break;
-
- default:
- BUG();
- }
- asm("ssync;");
- }
5、修改partition_info中的分区定义。
搞定。
需要注意的是,NandFlash和NorFlash检测完成后都后添加相应的分区, 此时用于系统启动的mtdblock号可能会发生变化。默认情况下,NorFlash加入3个分区,NandFlash加入2个分区,所以启动时的 root也相应地由/dev/mtdblock0改变为/dev/mtdblock5。
(lights_joy) |