一.先上一份日志
1.1.eth_mac_idb
lowmemorykiller: lowmem_shrink: convert oom_adj to oom_score_adj: lowmemorykiller: oom_adj 0 => oom_score_adj 0 lowmemorykiller: oom_adj 1 => oom_score_adj 58 lowmemorykiller: oom_adj 2 => oom_score_adj 117 lowmemorykiller: oom_adj 3 => oom_score_adj 176 lowmemorykiller: oom_adj 9 => oom_score_adj 529 lowmemorykiller: oom_adj 15 => oom_score_adj 1000 acc_open acc_release phy_power_on: enable = 1 11111111 err = 0 Read the Ethernet MAC address from IDB:e2:76:1e:08:31:07 eth0: device MAC address e2:76:1e:08:31:07 phy_rtl8201f_led_fixup in libphy: stmmac: probed eth0: PHY ID 001cc816 at 0 IRQ 0 (stmmac-0:00) active
1.2.etherm_addr_from_cpuid
lowmemorykiller: lowmem_shrink: convert oom_adj to oom_score_adj: lowmemorykiller: oom_adj 0 => oom_score_adj 0 lowmemorykiller: oom_adj 1 => oom_score_adj 58 lowmemorykiller: oom_adj 2 => oom_score_adj 117 lowmemorykiller: oom_adj 3 => oom_score_adj 176 lowmemorykiller: oom_adj 9 => oom_score_adj 529 lowmemorykiller: oom_adj 15 => oom_score_adj 1000 acc_open acc_release phy_power_on: enable = 1 11111111 err = 0 Read the Ethernet MAC address from IDB:00:00:00:00:00:00 etherm_addr_from_cpuid system_serial_low=75cef2b1,system_serial_high=4666831a the vendor enable_mac=0x1 use mac from vendor! the vendor mac e2:76:1e:08:31:23 eth0: device MAC address e2:76:1e:08:31:23 phy_rtl8201f_led_fixup in libphy: stmmac: probed eth0: PHY ID 001cc816 at 0 IRQ 0 (stmmac-0:00) active
二.分析一下源码 驱动读取MAC address流程
stmmac_check_ether_addr
eth_mac_idb
etherm_addr_from_cpuid
eth_hw_addr_random
2.1.Z:\ZK_R32X_RK3288_ANDROID5.1\ZK_R32X_RK3288_ANDROID5.1\kernel\drivers\net\ethernet\rockchip\gmac\stmmac_main.c
static void stmmac_check_ether_addr(struct stmmac_priv *priv) { if (!is_valid_ether_addr(priv->dev->dev_addr)) { priv->hw->mac->get_umac_addr((void __iomem *) priv->dev->base_addr, priv->dev->dev_addr, 0); if (!is_valid_ether_addr(priv->dev->dev_addr))
//rk 烧写工具 eth_mac_idb(priv->dev->dev_addr); if (!is_valid_ether_addr(priv->dev->dev_addr))
//cpuid 计算 lan Mac 地址 etherm_addr_from_cpuid(priv->dev->dev_addr); if(!is_valid_ether_addr(priv->dev->dev_addr))
//随机生成 eth_hw_addr_random(priv->dev); } pr_warn("%s: device MAC address %pM\n", priv->dev->name, priv->dev->dev_addr); }
2.2. Z:\ZK_R32X_RK3288_ANDROID5.1\ZK_R32X_RK3288_ANDROID5.1\kernel\drivers\net\ethernet\rockchip\eth_mac.c
2.2.1.eth_mac_idb
int eth_mac_idb(u8 *eth_mac) { int i; int err = 0; memset(eth_mac, 0, 6); err = eth_mac_read_from_IDB(eth_mac); if (err) return -1; printk("Read the Ethernet MAC address from IDB:"); for (i = 0; i < 5; i++) printk("%2.2x:", eth_mac[i]); printk("%2.2x\n", eth_mac[i]); return 0; }
2.2.2.etherm_addr_from_cpuid md5 加密
// Apply md5 process to system_serial_mac