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
  • Hi,

    You can use the alternative method mentioned in the documentation like this.

    struct net_if *iface;
    struct ethernet_req_params params;
    
    ...
    
    ret = net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, iface, &params, sizeof(struct ethernet_req_params));

    The MAC address need to be given to params.mac_address.addr. It can be provided directly in the code, for example:

    static const uint8_t my_mac_addr[6] = { 0x01, 0x02, 0x03, 0x04,  0x05,  0x07 };
    memcpy(params.mac_address.addr, my_mac_addr, 6);

    Kenneth

  • Hi Kenneth,

    Thanks for your reply. Wi-Fi stack starts to run successfully after I set the MAC manually. So I had tried to use sample's shell command wifi scan to check the APs nearby but the result is contrary to the actual deployment, at mean time, there are no error message. 

    I have no idea what this kinds of situation result from. If it means nrf7002's pin setting is incorrect?  

Reply
  • Hi Kenneth,

    Thanks for your reply. Wi-Fi stack starts to run successfully after I set the MAC manually. So I had tried to use sample's shell command wifi scan to check the APs nearby but the result is contrary to the actual deployment, at mean time, there are no error message. 

    I have no idea what this kinds of situation result from. If it means nrf7002's pin setting is incorrect?  

Children
Related