4.2. 让u-boot-1.3.4支持NOR FLASH
为了让u-boot-1.3.4支持支持Intel公司的NOR FLASH芯片E28F320J3A(4MB),必须修改/board/YF2410/flash.c和/include/configs/YF2410.h文件内容。
4.2.1. 修改flash.c
把/board/YF2410/flash.c文件的内容修改为清单14所示的内容。
清单1 修改后的flash.c文件
见附件flash.c
--------------------------------------------------------------------------------
4.2.2. 修改配置文件YF2410.h
在配置文件YF2410.h中修改NOR FLASH的配置,用清单16的配置替代清单15的配置即可。
清单15 修改前NOR FLASH的配置
--------------------------------------------------------------------------------
/*------------------------------------------------------------
* FLASH and environment organization
*/
#define CONFIG_AMD_LV400 1 /*uncomment this if you have a LV400 flash*/
#if 0
#define CONFIG_AMD_LV800 1 /*uncomment this if you have a LV800 flash*/
#endif
#define CFG_MAX_FLASH_BANKS 1 /*max number of memory banks*/
#ifdef CONFIG_AMD_LV800
#define PHYS_FLASH_SIZE 0x00100000 /*1MB*/
#define CFG_MAX_FLASH_SECT (19) /*max number of sectors on one chip*/
#define CFG_ENV_ADDR (CFG_FLASH_BASE + 0x0F0000) /*addr of environment*/
#endif
#ifdef CONFIG_AMD_LV400
#define PHYS_FLASH_SIZE 0x00080000 /*512KB*/
#define CFG_MAX_FLASH_SECT (11) /*max number of sectors on one chip*/
#define CFG_ENV_ADDR (CFG_FLASH_BASE + 0x070000) /*addr of environment*/
#endif
/*timeout values are in ticks*/
#define CFG_FLASH_ERASE_TOUT (5*CFG_HZ) /*Timeout for Flash Erase*/
#define CFG_FLASH_WRITE_TOUT (5*CFG_HZ) /*Timeout for Flash Write*/
#define CFG_ENV_IS_IN_FLASH 1
#define CFG_ENV_SIZE 0x10000 /*Total Size of Environment Sector*/
--------------------------------------------------------------------------------
清单16 修改后NOR FLASH的配置
--------------------------------------------------------------------------------
/*------------------------------------------------------------
* FLASH and environment organization
*/
#define CFG_FLASH_PROTECTION
#define CFG_MONITOR_BASE PHYS_FLASH_1
#define CFG_MAX_FLASH_BANKS 1 /*max number of memory banks*/
#define PHYS_FLASH_SIZE 0x004000000 /*4 MB*/
#define CFG_MAX_FLASH_SECT 128 /*max number of sectors on one chip*/
#define CFG_ENV_ADDR (PHYS_FLASH_1 + 0x40000) /*Addr of Environment Sector*/
/*timeout values are in ticks*/
#define CFG_FLASH_ERASE_TOUT (2*CFG_HZ) /*Timeout for Flash Erase*/
#define CFG_FLASH_WRITE_TOUT (2*CFG_HZ) /*Timeout for Flash Write*/
#define CFG_ENV_IS_IN_FLASH 1
#define CFG_ENV_SIZE 0x020000 /*Total Size of Environment Sector, 20K*/
--------------------------------------------------------------------------------
4.2.3. 测试对NOR FLASH的支持
重新编译u-boot.bin,烧写到NOR FLASH中,通过printenv,setenv,saveenv命令测试环境变量bootdelay是否修改成功,以测试NOR FLASH读写功能是否正确。具体操作参见清单17,18与19所示。
清单17 修改后的NOR FLASH配置
--------------------------------------------------------------------------------
U-Boot 1.3.4 (Aug 27 2008 - 16:55:40)
DRAM: 64 MB
Flash: 4 MB //大小识别正确
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
SMDK2410 #
--------------------------------------------------------------------------------
清单18 通过printenv,setenv,saveenv命令显示与修改环境变量
--------------------------------------------------------------------------------
SMDK2410 # printenv
bootcmd=bootm 80000
bootdelay=3
baudrate=115200
ethaddr=08:00:3e:26:0a:5b
ipaddr=135.1.2.150
serverip=135.1.2.192
netmask=255.255.255.0
stdin=serial
stdout=serial
stderr=serial
Environment size: 181/131068 bytes
SMDK2410 # setenv bootdelay 5
SMDK2410 #
Unknown command '' - try 'help'
SMDK2410 # printenv
bootcmd=bootm 80000
baudrate=115200
ethaddr=08:00:3e:26:0a:5b
ipaddr=135.1.2.150
serverip=135.1.2.192
netmask=255.255.255.0
stdin=serial
stdout=serial
stderr=serial
bootdelay=5
Environment size: 181/131068 bytes
SMDK2410 # saveenv
Saving Environment to Flash...
. done
Un-Protected 1 sectors
Erasing Flash...
Erase sector 2 at start addr 0x00040000 done
Erased 1 sectors
Writing to Flash... done
. done
Protected 1 sectors
--------------------------------------------------------------------------------
清单19 开发板断电重启,查看环境变量bootdelay是否保存成功
--------------------------------------------------------------------------------
U-Boot 1.3.4 (Aug 27 2008 - 16:55:40)
DRAM: 64 MB
Flash: 4 MB
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
SMDK2410 # printenv
bootcmd=bootm 80000
baudrate=115200
ethaddr=08:00:3e:26:0a:5b
ipaddr=135.1.2.150
serverip=135.1.2.192
netmask=255.255.255.0
bootdelay=5
stdin=serial
stdout=serial
stderr=serial
Environment size: 181/131068 bytes
SMDK2410 #
--------------------------------------------------------------------------------
在开发板断电重启后环境变量bootdelay值正确,证明在NOR FLASH上保存成功,可知对NOR FLASH的读写操作正确,u-boot对NOR FLASH的移植成功。
