nimble/hw: Remove reading public address fom UICR

If public address was not present in FICR there was fallback to try to
read this address from UICR. However, how address is stored in UICR is
not standarized anywhere so it's just a vendor decision how and where
to put it. In worst case this may read some other data from UICR and
use them as public address in case vendor is not aware of this behavior.

To avoid such problems, let's remove this fallback code. If needed,
public address can now be read from virtually anywhere (also UICR) and
set using new API: ble_ll_set_public_addr(). This should be done in
e.g. BSP code and it's up to vendor.
This commit is contained in:
Andrzej Kaczmarek
2019-01-25 07:12:56 -08:00
parent 6ab40a1eb1
commit 05c45c1318
2 changed files with 16 additions and 43 deletions
+7 -23
View File
@@ -60,33 +60,17 @@ uint8_t g_nrf_num_irks;
int
ble_hw_get_public_addr(ble_addr_t *addr)
{
int rc;
uint32_t addr_high;
uint32_t addr_low;
/* Does FICR have a public address */
rc = -1;
if ((NRF_FICR->DEVICEADDRTYPE & 1) == 0) {
addr_low = NRF_FICR->DEVICEADDR[0];
addr_high = NRF_FICR->DEVICEADDR[1];
rc = 0;
} else {
/* See if programmed in UICR. Upper 16 bits must all be zero */
addr_high = NRF_UICR->CUSTOMER[1];
if (addr_high < 65536) {
addr_low = NRF_UICR->CUSTOMER[0];
rc = 0;
}
if ((NRF_FICR->DEVICEADDRTYPE & 1) != 0) {
return -1;
}
if (!rc) {
/* Copy into device address. We can do this because we know platform */
memcpy(addr->val, &addr_low, 4);
memcpy(&addr->val[4], &addr_high, 2);
addr->type = BLE_ADDR_PUBLIC;
}
/* Copy into device address. We can do this because we know platform */
memcpy(addr->val, &NRF_FICR->DEVICEADDR[0], 4);
memcpy(&addr->val[4], &NRF_FICR->DEVICEADDR[1], 2);
addr->type = BLE_ADDR_PUBLIC;
return rc;
return 0;
}
/* Returns random static address or -1 if not present */
+9 -20
View File
@@ -66,33 +66,22 @@ uint8_t g_nrf_num_irks;
int
ble_hw_get_public_addr(ble_addr_t *addr)
{
int rc;
uint32_t addr_high;
uint32_t addr_low;
/* Does FICR have a public address */
rc = -1;
if ((NRF_FICR->DEVICEADDRTYPE & 1) == 0) {
addr_low = NRF_FICR->DEVICEADDR[0];
addr_high = NRF_FICR->DEVICEADDR[1];
rc = 0;
} else {
/* See if programmed in UICR. Upper 16 bits must all be zero */
addr_high = NRF_UICR->CUSTOMER[1];
if (addr_high < 65536) {
addr_low = NRF_UICR->CUSTOMER[0];
rc = 0;
}
if ((NRF_FICR->DEVICEADDRTYPE & 1) != 0) {
return -1;
}
if (!rc) {
/* Copy into device address. We can do this because we know platform */
memcpy(addr->val, &addr_low, 4);
memcpy(&addr->val[4], &addr_high, 2);
addr->type = BLE_ADDR_PUBLIC;
}
/* Copy into device address. We can do this because we know platform */
addr_low = NRF_FICR->DEVICEADDR[0];
addr_high = NRF_FICR->DEVICEADDR[1];
memcpy(addr->val, &addr_low, 4);
memcpy(&addr->val[4], &addr_high, 2);
addr->type = BLE_ADDR_PUBLIC;
return rc;
return 0;
}
/* Returns random static address or -1 if not present */