完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
Platform: RK3368
OS: Android 6.0 Kernel: 3.10.0 rk3368的Chip ID是从芯片eFuse中读取出来的。然后赋值给system_serial_low和system_serial_high. /proc/cpuinfo中的Serial字段就是用的这两个值。 arch/arm64/boot/dts/rk3368.dtsi efuse_256@ffb00000 { compatible = "rockchip,rk3368-efuse-256"; reg = <0x0 0xffb00000 0x0 0x8>; }; arch/arm/mach-rockchip/efuse.c static void __init rk3288_efuse_init(void) { int ret; pr_err("%sn", __func__); ret = rk3288_efuse_readregs(0, 32, efuse_buf); if (ret == 32) { if (efuse_buf[2] == 0x33 && efuse_buf[3] == 0x86) efuse.get_leakage = rk3368_get_leakage; else efuse.get_leakage = rk3288_get_leakage; efuse.efuse_version = rk3288_get_efuse_version(); efuse.process_version = rk3288_get_process_version(); rockchip_set_cpu_version((efuse_buf[6] >> 4) & 3); rk3288_set_system_serial(); } else { pr_err("failed to read eFuse, return %dn", ret); } } static void __init rk3288_set_system_serial(void) { int i; u8 buf[16]; for (i = 0; i < 8; i++) { buf = efuse_buf[8 + (i << 1)]; buf[i + 8] = efuse_buf[7 + (i << 1)]; } system_serial_low = crc32(0, buf, 8); system_serial_high = crc32(system_serial_low, buf + 8, 8); } 所以可以用Chip ID来生成wifi或者以太网的mac地址: Wi-Fi: net/rfkill/rfkill-wlan.c static int create_wifi_addr_from_system_serial() { if (system_serial_low != 0 && system_serial_high != 0) { wifi_custom_mac_addr[0] = (system_serial_high >> 8) & 0xfe;/* clear multicast bit */ wifi_custom_mac_addr[1] = system_serial_high | 0x02;/* set local assignment bit (IEEE802) */ wifi_custom_mac_addr[2] = system_serial_low >> 24; wifi_custom_mac_addr[3] = system_serial_low >> 16; wifi_custom_mac_addr[4] = system_serial_low >> 8; wifi_custom_mac_addr[5] = system_serial_low; } return 0; } int rockchip_wifi_mac_addr(unsigned char *buf) { char mac_buf[20] = {0}; @@ -620,6 +635,11 @@ int rockchip_wifi_mac_addr(unsigned char *buf) wifi_custom_mac_addr[2],wifi_custom_mac_addr[3],wifi_custom_mac_addr[4],wifi_custom_mac_addr[5]); LOG("falsh wifi_custom_mac_addr=[%s]n", mac_buf); + // from the system serial number + if (!is_valid_ether_addr(wifi_custom_mac_addr)) { + create_wifi_mac_from_system_serial(wifi_custom_mac_addr); + } + #ifdef ENABLE_WIFI_RAND_MAC 以太网: drivers/net/ethernet/rockchip/eth_mac.c int eth_mac_from_system_serial(u8 *addr) { if (system_serial_low != 0 && system_serial_high != 0) { pr_info("[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; } return 0; } +++ b/drivers/net/ethernet/rockchip/gmac/stmmac_main.c @@ -1691,6 +1691,8 @@ static void stmmac_check_ether_addr(struct stmmac_priv *priv) if (!is_valid_ether_addr(priv->dev->dev_addr)) eth_mac_idb(priv->dev->dev_addr); if (!is_valid_ether_addr(priv->dev->dev_addr)) + eth_mac_from_system_serial(priv->dev->dev_addr); + if (!is_valid_ether_addr(priv->dev->dev_addr)) eth_hw_addr_random(priv->dev); } 原作者:D00PING |
|
相关推荐 |
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1820 浏览 1 评论
synopsys 的design ware:DW_fpv_div,浮点数除法器,默认32位下,想提升覆盖率(TMAX),如果用功能case去提升覆盖率呢?
2269 浏览 1 评论
RK3588 GStreamer调试四路鱼眼摄像头四宫格显示报错
5092 浏览 1 评论
【飞凌嵌入式OK3576-C开发板体验】RKNN神经网络-YOLO图像识别
254 浏览 0 评论
【飞凌嵌入式OK3576-C开发板体验】SSH远程登录网络配置及CAN通讯
1336 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-19 11:30 , Processed in 0.506302 second(s), Total 38, Slave 32 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号