继 u-boot-2012.04.01移植四支持NAND Flash,继续修改代码支持DM9000。最后直接用NOR Flash里的u-boot烧写自己移植的u-boot到NAND,方便电脑没有并口或手上没有openjtag,照样能移植u-boot,当然有openjtag更方便。以后就直接通过tftp下载程序了
开发环境:
系统:ubuntu 10.04.4
单板:tq2440
NAND FLASH:K9F1216U0A 256MB
NOR Flash:EN29LV160AB 2MB
SDRAM:HY57V561620 x2 64MB
NET:DM9000AEP
编译器:arm-linux-gcc-4.3.2
搭建开发环境详见ubuntu 10.04.4开发环境配置。
目标:
1.支持NOR Flash启动,串口正常输出
2.支持NAND启动
3.支持DM9000网卡
继续完善u-boot.修改u-boot支持DM9000
change@change:~/Si/TQ2440/u-boot-2012.04.01$ vim drivers/net/Makefile
知道要定义宏CONFIG_DRIVER_DM9000
1.增加DM9000支持
include/configs/TQ2440.h修改如下:
/*
* Hardware drivers
*/
#if 0
#define CONFIG_CS8900 /* we have a CS8900 on-board */
#define CONFIG_CS8900_BASE 0x19000300
#define CONFIG_CS8900_BUS16 /* the Linux driver does accesses as shorts */
#else
#define CONFIG_DRIVER_DM9000
#define CONFIG_DM9000_BASE 0x20000000
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE + 4)
#endif
去掉以前arch/arm/lib/board.c 619:屏蔽的eth_initialize(gd->bd);
2.设置内存控制器
先暂且不变,有问题再说.默认的也行,下面可以不改
DM9000网卡使用的片选信号是nGCS 4,也就说明DM9000使用了BANK4。修改lowlevel_init.S(路径:board/TQ2440/lowlevel_init.S)。
/* BWSCON */
#define DW8 (0x0)
#define DW16 (0x1)
#define DW32 (0x2)
#define WAIT (0x1<<2)
#define UBLB (0x1<<3)
#define B1_BWSCON (DW32)
#define B2_BWSCON (DW16)
#if 0
#define B3_BWSCON (DW16 + WAIT + UBLB)
#endif
#define B3_BWSCON (DW16 + UBLB)
#define B4_BWSCON (DW16 + WAIT + UBLB)
#define B5_BWSCON (DW16)
#define B6_BWSCON (DW32)
#define B7_BWSCON (DW32)
修改前BANK3外接的CS8900网卡,将BANK3注释掉,修改数据宽度为16位,设置BANK4数据宽度16位,使用WAIT和nBE信号。
#define B4_Tacs 0x0 /*0clk */
#define B4_Tcos 0x3 /*4clk */
#define B4_Tacc 0x7 /* 14clk */
#define B4_Tcoh 0x1 /*1clk */
#define B4_Tah 0x3 /*4clk */
#define B4_Tacp 0x6 /*6clk */
#define B4_PMC 0x0 /* normal */
根据DM9000数据手册设置时序,具体见DM9000数据手册。
3.修改board/samsung/TQ2440/TQ2440.c:134
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_CS8900
rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
#endif
#ifdef CONFIG_DRIVER_DM9000 //add dm9000 support
rc = dm9000_initialize(bis);
#endif
return rc;
}
#endif
这里我遇到了一个问题困扰了一下午,加上DM9000后要么卡死要么data abort,可能新的u-boot太大了,我的内存分配还是按以前的,就出问题了
解决方法:将include/configs/TQ2440.h #define CONFIG_SYS_TEXT_BASE0x33f80000改为#define CONFIG_SYS_TEXT_BASE0x33f00000
4.编译、烧写、测试
change@change:~/Si/TQ2440/u-boot-2012.04.01$ make distclean
change@change:~/Si/TQ2440/u-boot-2012.04.01$ make TQ2440_config
Configuring for TQ2440 board...
change@change:~/Si/TQ2440/u-boot-2012.04.01$ make
单板拨到NOR启动,上电
U-Boot 2012.04.01 (Oct 25 2012 - 22:47:25)
CPUID: 32440001
FCLK: 400 MHz
HCLK: 100 MHz
PCLK: 50 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
Flash: 0 KB
NAND: 256 MiB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
SMDK2410 # set ipaddr 172.16.1.111
SMDK2410 # set gatewayip 172.16.1.1
SMDK2410 # set serverip 172.16.1.132
SMDK2410 # tftp 0x32000000 u-boot.bin
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:0c:29:4d:e4:f4
could not establish link
Using dm9000 device
TFTP from server 172.16.1.132; our IP address is 172.16.1.111
Filename 'u-boot.bin'.
Load address: 0x32000000
Loading: ##########################
done
Bytes transferred = 381056 (5d080 hex)
SMDK2410 # nand erase 0 0x80000
NAND erase: device 0 offset 0x0, size 0x80000
Erasing at 0x60000 -- 100% complete.
OK
SMDK2410 # nand write 0x32000000 0 0x80000
NAND write: device 0 offset 0x0, size 0x80000
524288 bytes written: OK
SMDK2410 #
烧写成功,拨到NAND启动 串口115200 8 n 1
U-Boot 2012.04.01 (May 03 2013 - 17:33:12)
CPUID: 32440001
FCLK: 400 MHz
HCLK: 100 MHz
PCLK: 50 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
NAND: 256 MiB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: dm9000
TQ2440 # printenv
baudrate=115200
bootdelay=5
ethact=dm9000
ipaddr=10.0.0.110
netmask=255.255.255.0
serverip=10.0.0.1
stderr=serial
stdin=serial
stdout=serial
Environment size: 160/65532 bytes
TQ2440 # set ipaddr 172.16.1.111
TQ2440 # set gatewayip 172.16.1.1
TQ2440 # set serverip 172.16.1.132
TQ2440 # ping 172.16.1.132
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: ff:ff:ff:ff:ff:ff
could not establish link
Using dm9000 device
host 172.16.1.132 is alive
TQ2440 #
可以看到支持网卡,能ping通·