How to configure nrf7002's MAC manually

I am trying to use nrf7002 in accord with nrf52840 to build a wifi sniffer recently. As a begineer of nrf70 series, I use wifi sample supplied in ncs 2.4.0 as a start, which is the "shell" sample. After programming sample app to nrf52840. I got some error form console like down below.

------------------------------------------------------------log from console------------------------------------------------------------

00> rtt:~$ [00:00:00.297,058] <inf> wifi_nrf: SPIM spi@4002f000: freq = 8 MHz
00>
00> rtt:~$ [00:00:00.297,088] <inf> wifi_nrf: SPIM spi@4002f000: latency = 0
00>
00> rtt:~$ [00:00:00.375,213] <inf> wifi_nrf: Firmware (v1.2.8.1) booted successfully
00>
00> rtt:~$ [00:00:00.403,717] <inf> wifi_nrf: wifi_nrf_fmac_otp_mac_addr_get: Invalid OTP MAC addr: 000000000000
00>
00> rtt:~$ [00:00:00.404,022] <err> wifi_nrf: wifi_nrf_if_start_zep: Invalid MAC address: 00:00:00:00:00:00
00>
00> rtt:~$ [00:00:00.409,149] <inf> fs_nvs: 8 Sectors of 4096 bytes
00> rtt:~$ [00:00:00.409,149] <inf> fs_nvs: alloc wra: 0, fe8
00> rtt:~$ [00:00:00.409,179] <inf> fs_nvs: data wra: 0, 0
00> rtt:~$ *** Booting Zephyr OS build v3.3.99-ncs1 ***
00> rtt:~$ Starting nrf52840dk_nrf52840 with CPU frequency: 64 MHz
00> rtt:~$ [00:00:00.409,790] <inf> wpa_supp: Successfully initialized wpa_supplicant

------------------------------------------------------------log from console------------------------------------------------------------


According error msg, I found a related ticket How to avoid the use of OTP memory in the nrf7002

 My first question, it seems that nrf7002's OTP need to be pre-programmed berfore using the wi-fi stack. However, I had buy a nrf7002DK that can directly run the sample mentioned above. If that means nrf7002 on the nrf7002DK, whose OTP had been pre-programmed when production? 

Anther question is, what if I prefer not to pre-programmed OTP but provide the MAC manually instead. From the application note down below, there indeed exist a way to set MAC manually but not mentioned in detail. If there has any example or guideline about it?

  

 Device Commissioning and Characterization application note

Parents Reply
  • Hi Rajendran Veerakaran,

            It can be achieved through net mgmt command. Please refer to the example down below.

    //header for net mgmt command
    #include <zephyr/net/net_if.h>
    #include <zephyr/net/ethernet.h>
    #include <zephyr/net/ethernet_mgmt.h>
    
    //code example setting the MAC manually
    struct net_if *iface = net_if_get_default();
    struct ethernet_req_params params;
    static const uint8_t my_mac_addr[6] = { 0x02, 0x80, 0xe1, 0x69,  0x80,  0xc2 };
    memcpy(params.mac_address.addr, my_mac_addr, 6);
    
    int ret = net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, iface, &params, sizeof(struct ethernet_req_params));
    if(ret) goto out;

    BR.

    Arvin Chen

Children
Related