This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Read local identity of nRF52832

Hello!

I am beating my head against my desk trying to read the local identity / hardware MAC address of my nRF52832 chip (On a Thingy:52) using Zephyr and nRFConnectSDK v1.2.

It is possible to advertise with it by using BT_LE_ADV_OPT_USE_IDENTITY but I would like to use it in other places.

I have also tried using bt_id_get to read it but without success.

Is there any standard method of doing this? Is it even possible?

EDIT: Ended up reading from FICR, but if you have any other suggestions please let me know Slight smile

Thanks

Joakim

  • You might find this useful:

    /**@note
     * Some module manufacturers define a MAC address stored within NRF_UICR, which matches the address inscribed on
     * the module. The Nordic examples use the Device Id in NRF_FICR to form a MAC address, which is different and fixed
     *
     * MAC Address
     * ===========
     * DA:88:19:2D:84:29 MM-7A530EC8 from DE5FDA88192D8429
     *
     * Last 2 bits in 48-bit stream - top 2 bits in last byte of Device Address
     * 00 Public
     * 01 Static
     * 10 Resolvable
     * 11 Non-Resolvable
     *
     * Note that even though the address is "Random", it is invariant and never changes
     * for a specific Nordic device as the NRF_FICR->DEVICEADDR registers are Read-Only
     */
    
    bool BleMacAdr(void)
    {
    #if defined(SOFTDEVICE_PRESENT)
      char Report[180];
      uint32_t Space = sizeof(Report)-1;
      // Get actual BLE address in case it is different from hardware register BLE address
      ble_gap_addr_t device_addr; // 48-bit address, LSB format
      sd_ble_gap_addr_get(&device_addr);
      snprintf(&Report[strlen(Report)], Space, "  - 64-bit Id %08X%08X\r\n", NRF_FICR->DEVICEADDR[1], NRF_FICR->DEVICEADDR[0]);
      Space = sizeof(Report) - strlen(Report) - 1;
      snprintf(&Report[strlen(Report)], Space, "  - BLE MAC: Peer %u, Type %u Addr %02X:%02X:%02X:%02X:%02X:%02X\r\n", 
                      device_addr.addr_id_peer, device_addr.addr_type, device_addr.addr[0], device_addr.addr[1],
                      device_addr.addr[2], device_addr.addr[3], device_addr.addr[4], device_addr.addr[5]);
      // Send report via whatever ..
    #endif
    }

    This give something like this:

     - 64-bit Id 01F4CFCDE1A8BAA2
     - BLE MAC: Peer 0, Type 1 Addr A2:BA:A7:E1:CD:CF

  • As long as CONFIG_BT_PRIVACY =n then the address should be generated from DEVICEADDR[0] and DEVICEADDR[1]

Related