diff --git a/drivers/ieee802154/ieee802154_nrf5.c b/drivers/ieee802154/ieee802154_nrf5.c index 56b1c57f8e..1036c56f03 100644 --- a/drivers/ieee802154/ieee802154_nrf5.c +++ b/drivers/ieee802154/ieee802154_nrf5.c @@ -23,6 +23,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include #include +#include #include #include #include @@ -69,16 +70,14 @@ static struct nrf5_802154_data nrf5_data; #if defined(CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE) #if defined(CONFIG_SOC_NRF5340_CPUAPP) +#if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) +#error "NRF_UICR->OTP is not supported to read from non-secure" +#else #define EUI64_ADDR (NRF_UICR->OTP) +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */ #else #define EUI64_ADDR (NRF_UICR->CUSTOMER) #endif /* CONFIG_SOC_NRF5340_CPUAPP */ -#else -#if defined(CONFIG_SOC_NRF5340_CPUAPP) || defined(CONFIG_SOC_NRF5340_CPUNET) -#define EUI64_ADDR (NRF_FICR->INFO.DEVICEID) -#else -#define EUI64_ADDR (NRF_FICR->DEVICEID) -#endif /* CONFIG_SOC_NRF5340_CPUAPP || CONFIG_SOC_NRF5340_CPUNET */ #endif /* CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE */ #if defined(CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE) @@ -108,15 +107,17 @@ static void nrf5_get_eui64(uint8_t *mac) uint32_t index = 0; #if !defined(CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE) + uint32_t deviceid[2]; + /* Set the MAC Address Block Larger (MA-L) formerly called OUI. */ mac[index++] = (IEEE802154_NRF5_VENDOR_OUI >> 16) & 0xff; mac[index++] = (IEEE802154_NRF5_VENDOR_OUI >> 8) & 0xff; mac[index++] = IEEE802154_NRF5_VENDOR_OUI & 0xff; -#endif -#if defined(CONFIG_SOC_NRF5340_CPUAPP) && \ - defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) -#error Accessing EUI64 on the non-secure mode is not supported at the moment + soc_secure_read_deviceid(deviceid); + + factoryAddress = (uint64_t)deviceid[EUI64_ADDR_HIGH] << 32; + factoryAddress |= deviceid[EUI64_ADDR_LOW]; #else /* Use device identifier assigned during the production. */ factoryAddress = (uint64_t)EUI64_ADDR[EUI64_ADDR_HIGH] << 32;