分类: LINUX
2008-04-26 11:39:36
修改flash.c
根据不同的flash芯片采用不同的flash程序接口,本开发板选用的是atmel的AT49BV
① 修改扇区大小和数目的定义
OrgDef OrgAT49BV16x
{
{ 8, 8*1024 }, /* 8 * 8kBytes sectors */
{ 31, 64*1024 } /* 31 * 64kBytes sectors */
};
改为
OrgDef OrgAT49BV16x
{
{ 8, 8*1024 }, /* 8 * 64kBytes sectors */
{ 63, 64*1024 } /* 63 *8kBytes sectors */
};
本芯片为71个扇区。
② 根据datasheet修改关于地址和读写命令的宏定义。
#define FLASH_BANK_SIZE 0x200000 /* 2 MB */
改为 #define FLASH_BANK_SIZE 0x400000 /* 4 MB */
/* AT49BV
#define FLASH_CODE1 0xAA
#define FLASH_CODE2 0x55
#define ID_IN_CODE 0x90
#define ID_OUT_CODE 0xF0
#define CMD_READ_ARRAY 0x
#define CMD_UNLOCK1 0x00AA
#define CMD_UNLOCK2 0x0055
#define CMD_ERASE_SETUP 0x0080
#define CMD_ERASE_CONFIRM 0x0030
#define CMD_PROGRAM 0x
#define CMD_UNLOCK_BYPASS 0x0020
#define MEM_FLASH_ADDR1 (*(volatile u16 *)(CFG_FLASH_BASE + (0x00005555<<1)))
#define MEM_FLASH_ADDR2 (*(volatile u16 *)(CFG_FLASH_BASE + (0x00002AAA<<1)))
#define IDENT_FLASH_ADDR1 (*(volatile u16 *)(CFG_FLASH_BASE + (0x0000555<<1)))
#define IDENT_FLASH_ADDR2 (*(volatile u16 *)(CFG_FLASH_BASE + (0x0000AAA<<1)))
修改为:
#define FLASH_CODE1 0x00AA00aa
#define FLASH_CODE2 0x00550055
#define ID_IN_CODE 0x00900090
#define ID_OUT_CODE 0x
#define CMD_READ_ARRAY 0x
#define CMD_UNLOCK1 0x00AA
#define CMD_UNLOCK2 0x0055
#define CMD_ERASE_SETUP 0x0080
#define CMD_ERASE_CONFIRM 0x0030
#define CMD_PROGRAM 0x
#define CMD_UNLOCK_BYPASS 0x00200020
#define MEM_FLASH_ADDR1 (*(volatile u16 *)(CFG_FLASH_BASE + (0x0000555<<1)))
#define MEM_FLASH_ADDR2 (*(volatile u16 *)(CFG_FLASH_BASE + (0x00002AA<<1)))
#define IDENT_FLASH_ADDR1 (*(volatile u32 *)(CFG_FLASH_BASE + (0x0000555<<2)))
#define IDENT_FLASH_ADDR2 (*(volatile u32 *)(CFG_FLASH_BASE + (0x0000AAA<<2)))
在
#define CMD_SECTOR_UNLOCK 0x0070
#define FLASH_BANK_SIZE 0x400000
printf ("flash_302: ");
(ATM_ID_BV1614A & FLASH_TYPEMASK))
info->flash_id |= ATM_ID_BV1614A & FLASH_TYPEMASK;
printf ("AT49BV1614A (16Mbit)\n");
}
info->flash_id |= ATM_ID_BV1614 & FLASH_TYPEMASK;
printf ("flash_302 (32Mbit)\n");
}
unsigned int flash_nb_blocks, sector;
unsigned int start_address;
OrgDef *pOrgDef;
ulong flashbase = 0;
memset (flash_info[i].protect, 0, CFG_MAX_FLASH_SECT );
flash_nb_blocks = sizeof (OrgAT49BV16x4A) / sizeof (OrgDef);
,然后保存推出,OK。
③ 去掉芯片自动识别,防治出以外错误。
注视掉if ((flash_info[i].flash_id & FLASH_TYPEMASK)……到else 144行-152行。
修改 config.mk
将TEXT_BASE = 0x
#define DST 0x
修改 include下面的头文件at91rm9200dk.h,
#define CONFIG_NR_DRAM_BANKS 1 //SDRAM bank数
#define PHYS_SDRAM 0x20000000 //基地址
#define PHYS_SDRAM_SIZE 0x2000000 //大小
#define PHYS_FLASH_1 0x10000000 //基地址
#define PHYS_FLASH_SIZE 0x400000 //大小
#define CFG_FLASH_BASE PHYS_FLASH_1 //别名
#define CFG_MAX_FLASH_BANKS 1 //总bank数
#define CFG_MAX_FLASH_SECT 71 //扇区总数
里面还可以添加一些环境变量。比如网络部分:
#define CONFIG_DEFAULT_ENVIRONMENT
#define CONFIG_BOARDNAME "AT91RM9200DK"
#define CONFIG_ETHADDR "00:11:22:33:44:55"
#define CONFIG_IPADDR "192.168.0.110"
#define CONFIG_SERVERIP "192.168.0.100"
#define CONFIG_GATEWAYIP "192.168.0.1"
#define CONFIG_BOOTCOMMAND "tftp 0x20008000 uImage; tftp 0x21000000 ramdisk; go 0x20008000"
#define CONFIG_DEFAULT_KERNEL "2.6.17"