上一篇文章已经让uboot2014.10在TQ335x板子上运行起来,但是网卡驱动还没有移植,不能使用tftp来下载镜像,这样不方便调试,现在就把RTL8211E网卡驱动移植到uboot上。
uboot2014.10的源码中,已经有rtl8211E网卡的Phy驱动(u-boot2014.10/drivers/net/phy/realtek.c),我们使用Ti的cpsw(TI Common Platform Ethernet Switch (CPSW))方式来驱动网卡。
单板:TQ335x Core-c
编译环境:ubuntu12.04
uboot版本:2014.10
1、修改 (include\configs\am335x_evm.h) ,定义rtl8211相关的支持宏,打开这些宏后phy.c会注册rtl8211e的驱动。
/* Network. */
#define CONFIG_PHY_GIGE
#define CONFIG_PHYLIB
/*#define CONFIG_PHY_SMSC*/
#define CONFIG_PHY_REALTEK
#define CONFIG_DRIVER_TI_CPSW
2、修改(board\ti\am335x\board.c)中的board_eth_init(bd_t *bis)函数,因为我这个只用于TQ335x这块单板,我就直接把其他不想关的代码删除了。
#define ETH_ALEN6
int board_eth_init(bd_t *bis)
{
uint8_t mac_addr[6];
uint32_t mac_hi, mac_lo;
u_int32_t i;
struct am335x_baseboard_id header;
if (read_eeprom(&header) < 0)
puts("Could not get board ID.\n");
if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
debug(" not set. Reading from E-fuse\n");
/* try reading mac address from efuse */
mac_lo = __raw_readl(MAC_ID0_LO);
mac_hi = __raw_readl(MAC_ID0_HI);
mac_addr[0] = mac_hi & 0xFF;
mac_addr[1] = (mac_hi & 0