void MacSet(int port) { char* buf; int length;
if (sysNvRamGet((UINT8 *)&npeMacAddr.macAddress, IX_IEEE803_MAC_ADDRESS_SIZE, nvRamNpeMacAddr[port]) == ERROR) { printf("ixe %d - Unable to read MAC address from non-volatile storage!\n" , port );
} /* Check for a valid MAC address - Only compare first three bytes */ npeMacAddr.macAddress[5] += port;
printf("ixe ETH PHY %d Hard Coded MAC address is: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n" , port ,npeMacAddr.macAddress[0], npeMacAddr.macAddress[1] ,npeMacAddr.macAddress[2], npeMacAddr.macAddress[3] ,npeMacAddr.macAddress[4], npeMacAddr.macAddress[5]);
printf ("npeMacAddr.macAddress0\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[0]=atoi(buf); printf ("npeMacAddr.macAddress1\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[1]=atoi(buf);
printf ("npeMacAddr.macAddress2\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[2]=atoi(buf);
printf ("npeMacAddr.macAddress3\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[3]=atoi(buf);
printf ("npeMacAddr.macAddress4\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[4]=atoi(buf);
printf ("npeMacAddr.macAddress5\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[5]=atoi(buf);
npeMacAddr.macAddress[5] += port;
printf("ixe ETH PHY %d Hard Coded MAC address is: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n" , port ,npeMacAddr.macAddress[0], npeMacAddr.macAddress[1] ,npeMacAddr.macAddress[2], npeMacAddr.macAddress[3] ,npeMacAddr.macAddress[4], npeMacAddr.macAddress[5]); }
不能提供你源代码,提供一个思路,我们就是这么做的。
将mac地址保存在flash上的一个固定地址处,每次更改flash就重新写到这里,需要用地址的时候就从这里读取,写连个操作flash的接口就好了,另外就是修改地址时逻辑判断的一个函数,在那个函数中调用写接口写进去。
通过ipmacset命令后,ip地址改了,MAC 也改了,可是这里去ping不通, 并且bootline中的目标板的地址却还是原来的,启动时显示的mac还是原来的,奇怪!!
-> ipmacset
ixe0 MAC address: 00:02:b3:3c:16:68 ixe1 MAC address: 00:02:b3:3c:16:69
ixe0 IP address: 169.254.113.143 ixe1 IP address: 169.254.113.144
Any Changes (y/n)> y
Change a MAC address (y/n)> y ixe0 MAC address: 00:02:b3:3c:16:68 00:02:b3:3c:16:68 ixe1 MAC address: 00:02:b3:3c:16:69 00:02:b3:3c:16:64
Change ixe IP address (y/n)> y ixe0 IP address: 169.254.113.143 169.254.113.146 ixe1 IP address: 169.254.113.144 169.254.113.147
ixe0 MAC address: 00:02:b3:3c:16:68 ixe1 MAC address: 00:02:b3:3c:16:64
ixe0 IP address: 169.254.113.146 ixe1 IP address: 169.254.113.147
Any Changes (y/n)> y
Change a MAC address (y/n)> n
Change ixe IP address (y/n)> n
ixe0 MAC address: 00:02:b3:3c:16:68 ixe1 MAC address: 00:02:b3:3c:16:64
ixe0 IP address: 169.254.113.146 ixe1 IP address: 169.254.113.147
Any Changes (y/n)> n
Writing interface data to non-volatile storage... New configuration written, changes will take effect after a reboot value = 0 = 0x0 -> reboot 系统重新启动后。。。
-> ipmacset
ixe0 MAC address: 00:02:b3:3c:16:68 ixe1 MAC address: 00:02:b3:3c:16:64
ixe0 IP address: 169.254.113.146 ixe1 IP address: 169.254.113.147
Any Changes (y/n)> n value = 0 = 0x0 ->
-> ping "169.254.113.146",1,0 ping: timeout no answer from 169.254.113.146 value = -1 = 0xffffffff -> ping "169.254.113.147",1,0 ping: timeout no answer from 169.254.113.147 value = -1 = 0xffffffff -> ip地址从这里看是改了,MAC 也改了,可是这里去ping不通, 并且bootline中的目标板的地址却还是原来的,奇怪!! '.' = clear field; '-' = go to previous field; ^D = quit
boot device : ixe1 processor number : 0 host name : host file name : vxworks inet on ethernet (e) : 169.254.113.144 inet on backplane (b): host inet (h) : 169.254.113.140 gateway inet (g) : user (u) : xjb ftp password (pw) (blank = use rsh): 1 flags (f) : 0x0 target name (tn) : startup script (s) : other (o) : ixe0 value = 0 = 0x0
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【换取逻辑分析仪】自制底板并驱动ArduinoNanoRP2040ConnectLCD扩展板被打赏47分 | |
【分享评测,赢取加热台】RISC-V GCC 内嵌汇编使用被打赏38分 | |
【换取逻辑分析仪】-基于ADI单片机MAX78000的简易MP3音乐播放器被打赏48分 | |
我想要一部加热台+树莓派PICO驱动AHT10被打赏38分 | |
【换取逻辑分析仪】-硬件SPI驱动OLED屏幕被打赏36分 | |
换逻辑分析仪+上下拉与多路选择器被打赏29分 | |
Let'sdo第3期任务合集被打赏50分 | |
换逻辑分析仪+Verilog三态门被打赏27分 | |
换逻辑分析仪+Verilog多输出门被打赏24分 | |
【分享评测,赢取加热台】使用8051单片机驱动WS2812被打赏40分 |