Hello,
I'm currently working on a custom board using nRF5340 and nR7002 and the nRF7002 MAC address is not yet set in the OTP.
After reading this post, I'm now trying to use the NET_REQUEST_ETHERNET_SET_MAC_ADDRESS to change it manually before using the interface.
My function to change the MAC address is :
int8_t wifi_set_mac_address(){ struct net_if *iface = net_if_get_default(); uint8_t mac_addr[6] = {0xF0, 0xCE, 0x36, 0x00, 0x00, 0x4A}; struct ethernet_req_params eth_param; memcpy(eth_param.mac_address.addr, mac_addr, 6); if(net_if_down(iface)){ printk("<Err> Couldn't shutdown WiFi interface\n"); return -1; } printk("<Inf> Setting MAC address\n"); if(net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS,iface, ð_param, sizeof(struct ethernet_req_params))){ printk("<Err> Couldn't set new MAC Address\n"); return -2; } int ret = memcmp(net_if_get_link_addr(iface)->addr, mac_addr, sizeof(mac_addr)); if(ret){ printk("<Err> Couldn't change MAC address\n"); } if(net_if_up(iface)){ printk("<Err> Couldn't wake up interface\n"); return -3; } return 0; }
After a few tries, it appears that the net_if_down() function fails as if the interface wasn't yet up and couldn't be taken down. Unfortunately, if I comment this section it seems that I manage to change the MAC address but I consistently get a Core dump when trying to use the function net_if_up() function.
Do you have any idea on what could cause this core dump ? I though I had followed the example code but I may have made some mistakes.
Thanks,
Regards