Skip to content

Commit 7f467f2

Browse files
committed
fallback to device addr if no valid mac found in UICR
1 parent 72ad24e commit 7f467f2

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed
-528 Bytes
Binary file not shown.

tag_fw/Newton_M3_Universal-ota.bin

-528 Bytes
Binary file not shown.

tag_fw/hal/Newton_M3_nRF52811/HAL_Newton_M3.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,31 @@ void getTemperature() {
138138
}
139139

140140
void boardGetOwnMac(uint8_t *mac) {
141-
mac[0] = tag.macSuffix & 0xFF;
142-
mac[1] = tag.macSuffix >> 8;
143-
mac[2] = (NRF_UICR->CUSTOMER[0]) & 0xFF;
144-
mac[3] = (NRF_UICR->CUSTOMER[0] >> 8) & 0xFF;
145-
mac[4] = (NRF_UICR->CUSTOMER[0] >> 16) & 0xFF;
146-
mac[5] = (NRF_UICR->CUSTOMER[0] >> 24);
147-
mac[6] = 0;
148-
mac[7] = 0;
149-
uint8_t cksum = 0;
150-
for (uint8_t c = 0; c < 8; c++) {
151-
cksum ^= mac[c];
152-
cksum ^= mac[c] >> 4;
141+
if (NRF_UICR->CUSTOMER[0] == 0xFFFFFFFF) {
142+
mac[0] = (NRF_FICR->DEVICEADDR[1]) & 0xFF;
143+
mac[1] = (NRF_FICR->DEVICEADDR[1] >> 8) & 0xFF;
144+
mac[2] = (NRF_FICR->DEVICEADDR[1] >> 16) & 0xFF;
145+
mac[3] = (NRF_FICR->DEVICEADDR[1] >> 24);
146+
mac[4] = (NRF_FICR->DEVICEADDR[0]) & 0xFF;
147+
mac[5] = (NRF_FICR->DEVICEADDR[0] >> 8) & 0xFF;
148+
mac[6] = (NRF_FICR->DEVICEADDR[0] >> 16) & 0xFF;
149+
mac[7] = (NRF_FICR->DEVICEADDR[0] >> 24);
150+
} else {
151+
mac[0] = tag.macSuffix & 0xFF;
152+
mac[1] = tag.macSuffix >> 8;
153+
mac[2] = (NRF_UICR->CUSTOMER[0]) & 0xFF;
154+
mac[3] = (NRF_UICR->CUSTOMER[0] >> 8) & 0xFF;
155+
mac[4] = (NRF_UICR->CUSTOMER[0] >> 16) & 0xFF;
156+
mac[5] = (NRF_UICR->CUSTOMER[0] >> 24);
157+
mac[6] = 0;
158+
mac[7] = 0;
159+
uint8_t cksum = 0;
160+
for (uint8_t c = 0; c < 8; c++) {
161+
cksum ^= mac[c];
162+
cksum ^= mac[c] >> 4;
163+
}
164+
mac[0] += cksum & 0x0F;
153165
}
154-
mac[0] += cksum & 0x0F;
155166
}
156167

157168
void watchdog_enable(int timeout) {

0 commit comments

Comments
 (0)