在board/freescale/mx6sabresd/mx6sabresd.c中,添加如下代码,下面代码通过md5计算出一个位mac地址,分配给网口 void generate_mac_by_uuid(void) { u32 inbuf[2]; u8 outbuf[16]; char mac[24]; memset(mac, sizeof(mac), 0); /* read uuid for mac */ fuse_read(0,1,inbuf); fuse_read(0,2,inbuf + 1); md5((u8 *) inbuf, (2 * sizeof(u32)), outbuf); outbuf[0] &= 0xFE; outbuf[0] |= 0x02; sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X", outbuf[0], outbuf[1], outbuf[2], outbuf[3], outbuf[4], outbuf[5]); setenv("ethaddr", mac); setenv("fec_mac", mac); saveenv(); } |
|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )
GMT+8, 2024-11-22 10:16
Powered by Discuz! X3.4
© 2001-2013 Comsenz Inc.