
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
回复
打赏帖 | |
---|---|
【瑞萨RA2E1开发板】:使用ADC功能实现位移传感器采集方案被打赏20分 | |
【nRF7002DK】基于sht30的温湿度计被打赏20分 | |
【nRF7002DK】日志打印被打赏20分 | |
rtthread硬件加密-5hash加密分析被打赏10分 | |
【STM32F769】SD卡驱动及其调试经验分享被打赏32分 | |
【分享开发笔记,赚取电动螺丝刀】使用看门狗降低系统隐藏bug触发概率被打赏18分 | |
【STM32F769】调试SD驱动,由于其时钟配置不对引起的错误以及排查记录被打赏35分 | |
【分享开发笔记,赚取电动螺丝刀】MCUXpressoConfigTools配置外设时的异常解决被打赏24分 | |
C语言函数宏的三种封装方式被打赏50分 | |
【换取手持示波器】NUCLEO-F429ZI Mongoose移植被打赏30分 |