RK3288 android 7.1.2 使用CPU Serial固定USB以太网MAC地址

diff --git a/kernel/drivers/net/usb/r8152.c b/kernel/drivers/net/usb/r8152.c
old mode 100644
new mode 100755
index 2bb336c..05321d0
--- a/kernel/drivers/net/usb/r8152.c
+++ b/kernel/drivers/net/usb/r8152.c
@@ -26,6 +26,7 @@
 #include <linux/mdio.h>
 #include <linux/usb/cdc.h>
 #include <linux/suspend.h>
+#include <asm/system_info.h>
 
 /* Information for net-next */
 #define NETNEXT_VERSION		"08"
@@ -649,6 +650,21 @@ enum tx_csum_stat {
 	TX_CSUM_NONE
 };
 
+int eth_mac_from_system_serial(u8 *addr)
+{
+	if (system_serial_low != 0 && system_serial_high != 0) {
+		printk("[eth]Create an address from the system serial number.\n");
+		addr[0] = (system_serial_high >> 24) & 0xfe;/* clear multicast bit */
+		addr[1] = (system_serial_high >> 16) | 0x02;/* set local assignment bit (IEEE802) */
+		addr[2] = system_serial_low >> 24;
+		addr[3] = system_serial_low >> 16;
+		addr[4] = system_serial_low >> 8;
+		addr[5] = system_serial_low;
+		printk("#############%s: ------------%pM\n",__func__,addr);
+	}
+	return 0;
+}
+
 /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
  * The RTL chips use a 64 element hash table based on the Ethernet CRC.
  */
@@ -4306,6 +4322,10 @@ static int rtl8152_probe(struct usb_interface *intf,
 
 	tp->rtl_ops.init(tp);
 	set_ethernet_addr(tp);
+	//======================================
+	msleep(200);
+	eth_mac_from_system_serial(netdev->dev_addr);
+	//======================================
 
 	usb_set_intfdata(intf, tp);
 	netif_napi_add(netdev, &tp->napi, r8152_poll, RTL8152_NAPI_WEIGHT);

技术交流群: RK3288 android 7.1.2 使用CPU Serial固定USB以太网MAC地址微信号RK3288 android 7.1.2 使用CPU Serial固定USB以太网MAC地址

上一篇:Serial Box for Mac(软件序列号查询软件)


下一篇:老王家4.9元ESP8266温湿度传感器(光和未来)不开壳无损制作网页温湿度计