kernel/arch/arm/configs/msm8909-1gb_defconfig
通过menuconfig的搜索功能了解到内核配置中有关于这个驱动的源代码,但是尚未编译进内核,所以这里加入相关配置:
CONFIG_MII=y
CONFIG_USB_RTL8152=y
修改/kernel/drivers/net/usb/r8152.c 随机mac
static int rtl8152_set_mac_address(struct net_device *netdev, void *p);
static inline void set_ethernet_addr(struct r8152 *tp)
{
struct net_device *dev = tp->netdev;
struct sockaddr sa;
int ret;
ret = pla_ocp_read(tp, PLA_IDR, 8, sa.sa_data);
if (ret < 0) {
netif_err(tp, probe, dev, “ether addr fail\n”);
} else if (!is_valid_ether_addr(sa.sa_data)) {
netif_warn(tp, probe, dev, “Invalid ether addr\n”);
eth_hw_addr_random(dev);
memcpy(sa.sa_data, dev->dev_addr, ETH_ALEN);//unsigned char dev_addr[MAX_ADDR_LEN] ETH_ALEN = 6
rtl8152_set_mac_address(dev, &sa);
} else {
if (tp->version == RTL_VER_01)
memcpy(dev->dev_addr, sa.sa_data, ETH_ALEN);
else
ret = rtl8152_set_mac_address(dev, &sa);
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
#endif
}
}