Not able to set the MAC address

I was programming wifi scan example with nrf7002dk_nrf5340_cpuapp configuration. The mac address was not setting by default so I did it manually by using the function provided below.

Still not working.

void wifi_set_mac_address(){
    struct net_if *iface = net_if_get_default();
    char mac_addr_change[]={0xF3,0xF7,0xB9,0x21,0x68,0x24};
    struct ethernet_req_params params;
    int ret;

    memcpy(params.mac_address.addr, mac_addr_change, 6);
    net_if_down(iface);

    ret = net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, iface,
            &params, sizeof(struct ethernet_req_params));
    if(ret != 0) {
        LOG_ERR("unable to change mac address");
        return;
    }
    ret = memcmp(net_if_get_link_addr(iface)->addr, mac_addr_change,
            sizeof(mac_addr_change));
    if(ret != 0) {
        LOG_ERR("mac address change failed");
        return;
    }
    LOG_DBG("MAC changed to %x:%x:%x:%x:%x:%x\n", \
    mac_addr_change[0], mac_addr_change[1], mac_addr_change[2], \
    mac_addr_change[3], mac_addr_change[4], mac_addr_change[5]);
    net_if_up(iface);
}
Also enabled 
CONFIG_NET_NATIVE=y in prj.conf file
Parents Reply Children
  • Yes I went through the code
    Actually the module which I am using doesn't have any serial port so if I even want to change it through otp command I am not able to as I don't know where to run the command

    After adding the code also to set the mac address manually, it gives me the below result

    [00:00:00.016,479] <err> wifi_nrf: hal_rpu_reg_read: Error !! Value read at addr_offset = 400 is = FFFFFFFF

    [00:00:00.016,571] <err> wifi_nrf: hal_rpu_irq_enable: Reading from Root interrupt register failed

    [00:00:00.016,632] <err> wifi_nrf: nrf_wifi_hal_dev_add: hal_rpu_irq_enable failed

    [00:00:00.016,815] <err> wifi_nrf: nrf_wifi_fmac_dev_add: nrf_wifi_hal_dev_add failed

    [00:00:00.016,845] <err> wifi_nrf: nrf_wifi_fmac_dev_add_zep: nrf_wifi_fmac_dev_add failed

    [00:00:00.016,845] <err> wifi_nrf: nrf_wifi_if_init_zep: nrf_wifi_fmac_dev_add_zep failed

    [00:00:00.031,616] <err> wifi_nrf: hal_rpu_reg_read: Error !! Value read at addr_offset = 400 is = FFFFFFFF

    [00:00:00.031,707] <err> wifi_nrf: hal_rpu_irq_enable: Reading from Root interrupt register failed

    [00:00:00.031,738] <err> wifi_nrf: nrf_wifi_hal_dev_add: hal_rpu_irq_enable failed

    [00:00:00.031,921] <err> wifi_nrf: nrf_wim

  • Hi Charlie

    I was able to set the mac address
    But after that also it is not able to scan the wifi networks

    <inf> wifi_nrf: SPIM spi@a000: freq = 8 MHz

    [00:00:00.005,096] <inf> wifi_nrf: SPIM spi@a000: latency = 0

    [00:00:00.005,584] <err> wifi_nrf: hal_rpu_reg_read: Error !! Value read at addr_offset = 400 is = FFFFFFFF

    [00:00:00.005,676] <err> wifi_nrf: hal_rpu_irq_enable: Reading from Root interrupt register failed

    [00:00:00.005,737] <err> wifi_nrf: nrf_wifi_hal_dev_add: hal_rpu_irq_enable failed

    [00:00:00.005,889] <err> wifi_nrf: nrf_wifi_fmac_dev_add: nrf_wifi_hal_dev_add failed

    [00:00:00.005,920] <err> wifi_nrf: nrf_wifi_fmac_dev_add_zep: nrf_wifi_fmac_dev_add failed

    [00:00:00.005,950] <err> wifi_nrf: nrf_wifi_if_init_zep: nrf_wifi_fmac_dev_add_zep failed

    wifi_nrf: hal_rpu_reg_read: Error !! Value read at addr_offset =[00:08:01.023,834] <err> wifi_nrf: nrf_wifi_disp_scan_zep: Interface not UP

    [00:08:01.023,864] <err> scan: Scan request failed
    [00:08:11.024,047] <err> wifi_nrf: nrf_wifi_disp_scan_zep: Interface not UP

    I get these kind of errors

Related