forked from Poco-Ye/rk-ethernet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtl8152解决MAC地址为空导致获取不了ip_kernel3.10.diff
38 lines (34 loc) · 1.42 KB
/
rtl8152解决MAC地址为空导致获取不了ip_kernel3.10.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
1. CONFIG_USB_RTL8152=n
2. 打上从flash保留区(通过PC工具预先烧写)读取MAC地址的补丁
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
old mode 100644
new mode 100755
index 3d50e7d..1af08ed
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1595,6 +1595,26 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
if ((dev->driver_info->flags & FLAG_WWAN) != 0)
SET_NETDEV_DEVTYPE(net, &wwan_type);
+#if 1
+ if ((net->dev_addr[0] == 0x00) &&
+ (net->dev_addr[1] == 0x00) &&
+ (net->dev_addr[2] == 0x00) &&
+ (net->dev_addr[3] == 0x00) &&
+ (net->dev_addr[4] == 0x00) &&
+ (net->dev_addr[5] == 0x00) )
+ {
+ extern int eth_mac_idb(u8 *eth_mac);
+
+ printk("[MAC] try mac addr from idb first.\n");
+ eth_mac_idb(net->dev_addr);
+ if (!is_valid_ether_addr(net->dev_addr))
+ {
+ printk("[MAC] no mac addr in idb, use random mac addr.\n");
+ random_ether_addr(net->dev_addr);
+ }
+ }
+#endif
+
status = register_netdev (net);
注意:如果使用双以太网,一个是GMAC,另一个是USB以太网,这样子修改后会导致两个以太网卡MAC地址一样,都是使用flash保留区中的。
可对上面补丁中的MAC地址net->dev_addr修改一个bit加以区分