关于ubuntu每次启动MAC地址都发生变化的问题
刷了ubuntu18.04,每次启动MAC地址都会变化,下载了论坛里介绍的UpgradeDllTool和WNpctool,读写MAC地址都失败,不知道有什么办法没有。问题没解决,我加您QQ了,请通过一下!
好啦,我自己搞定了:
1、小板子上执行 dmesg | grep mac,找到大致下面信息,发现mac地址的获取是通过rk_get_eth_addr这个函数。
rk_get_eth_addr: rk_vendor_read eth mac address failed (-1)
rk_get_eth_addr: rk_vendor_write eth mac address failed (-1)
rk_get_eth_addr: mac address: cc:10:ad:eb:70:55
2、执行grep rk_get_eth_addr -r ./定位rk_get_eth_addr函数在kernel/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c文件里
3、找到这个函数,在if (ret != 6 || is_zero_ether_addr(addr)) {这段代码的后面加上这些内容:
/*modified by woodrow*/
union {
unsigned long ul;
unsigned char uc;
} cc;
//random_ether_addr(addr);
// dev_err(dev, "%s: generate random eth mac address: %02x:%02x:%02x:%02x:%02x:%02x",
// __func__, addr, addr, addr,
// addr, addr, addr);
unsigned long system_low = (unsigned long)system_serial_low;
unsigned long system_high = (unsigned long)system_serial_high;
dev_err(dev, "%s: rk_vendor_read eth mac address failed (%d)", __func__, ret);
dev_err(dev, "%s: system_serial_low (%lu), system_serial_high (%lu).\n", __func__, system_low, system_high);
cc.ul = system_low;
addr = 0xcc;
addr = 0x10;
addr = cc.uc;
addr = cc.uc;
addr = cc.uc;
addr = cc.uc;
/*modified by woodrow*/
这段代码的用途是,当没有在vendor_storage里读到mac地址的时候,不是随机产生一个mac地址,而是将cpu序列号作为mac地址的一部分。cpu序列号:system_serial_low和system_serial_high是2个全局变量,需要引入头文件:#include <asm/system_info.h>才能使用。
页:
[1]