Skip to content

Commit 28da197

Browse files
committed
modules: memfault: Use hw_id for default Memfault device id
Simplify the options for `MEMFAULT_NCS_DEVICE_ID_*`: - `MEMFAULT_NCS_DEVICE_ID_HW_ID` (new default) - use the `hw_id` provided device id, which is also what nRF Cloud uses for device identity - `MEMFAULT_NCS_DEVICE_ID_STATIC` used to set a custom build-time defined static device id, primarily only useful for testing - `MEMFAULT_NCS_DEVICE_ID_RUNTIME` use a runtime-applied device id, commonly used when device serial is written into settings at manufacturing time, for example Additionally, modify the default `hw_id`-provided value, depending on system configuration. In order: - if `MEMFAULT_NCS_DEVICE_ID_IMEI || NRF_MODEM_LIB` is selected, use IMEI. Note that `MEMFAULT_NCS_DEVICE_ID_IMEI` is kept for backwards compatibility, but is marked deprecated - if `BOARD_NRF7002DK_NRF5340_CPUAPP` is selected, use network MAC (special case) - finally, if `BT` is selected, use BLE MAC - otherwise, the default `HW_ID_LIBRARY_SOURCE_DEVICE_ID` (chip UID) will be used This means that LTE customers will get a default Memfault device id matching IMEI, and matching the nRF Cloud device id. Bluetooth customers will get a default Memfault device id matching BLE MAC (debatable whether it would be preferrable to default to chip UID instead, but BLE MAC is used for consistency with IMEI, i.e. the device id default convention is "network id"). Signed-off-by: Noah Pendleton <[email protected]>
1 parent e02b7a6 commit 28da197

File tree

7 files changed

+39
-22
lines changed

7 files changed

+39
-22
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,23 @@ Memfault integration
910910
* Removed a metric for the tracking Bluetooth TX thread unused stack ``ncs_bt_tx_unused_stack``.
911911
The thread in question was removed in Zephyr v3.7.0.
912912

913+
* Simplify the options for ``CONFIG_MEMFAULT_NCS_DEVICE_ID_*``:
914+
915+
* :kconfig:option:`CONFIG_MEMFAULT_NCS_DEVICE_ID_HW_ID` (new default) - use the `hw_id` provided device id, which is also what nRF Cloud uses for device identity
916+
* :kconfig:option:`CONFIG_MEMFAULT_NCS_DEVICE_ID_STATIC` used to set a custom build-time defined static device id, primarily only useful for testing
917+
* :kconfig:option:`CONFIG_MEMFAULT_NCS_DEVICE_ID_RUNTIME` use a runtime-applied device id, commonly used when device serial is written into settings at manufacturing time, for example
918+
919+
Additionally, modify the default `hw_id`-provided value, depending on system configuration. In order:
920+
921+
* If `MEMFAULT_NCS_DEVICE_ID_IMEI || NRF_MODEM_LIB` is selected, use IMEI. Note that :kconfig:option:`CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI` is kept for backwards compatibility, but is marked deprecated
922+
* Else if `BOARD_NRF7002DK_NRF5340_CPUAPP` is selected, use network MAC address (special case for backwards compatibility)
923+
* Else if `BT` is selected, use Bluetooth MAC address
924+
* Otherwise, the default `HW_ID_LIBRARY_SOURCE_DEVICE_ID` (chip UID) will be used
925+
926+
This means that LTE customers will get a default Memfault device id matching IMEI, and matching the nRF Cloud device id, instead of requiring a static ID for all nRF91-series devices other than a select list of boards (previously: ``(BOARD_NRF9160DK_NRF9160_NS || BOARD_NRF9161DK_NRF9161_NS || BOARD_THINGY91_NRF9160_NS)``).
927+
928+
Bluetooth devices will have a default Memfault device id set to the Bluetooth MAC address.
929+
913930
AVSystem integration
914931
--------------------
915932

modules/memfault-firmware-sdk/Kconfig

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,20 @@ if MEMFAULT_DEVICE_INFO_BUILTIN
3333

3434
choice
3535
prompt "Memfault device ID generation method"
36-
default MEMFAULT_NCS_DEVICE_ID_IMEI if (BOARD_NRF9160DK_NRF9160_NS || BOARD_NRF9161DK_NRF9161_NS || BOARD_THINGY91_NRF9160_NS)
37-
default MEMFAULT_NCS_DEVICE_ID_NET_MAC if BOARD_NRF7002DK_NRF5340_CPUAPP
38-
default MEMFAULT_NCS_DEVICE_ID_STATIC
36+
default MEMFAULT_NCS_DEVICE_ID_HW_ID
3937

4038
config MEMFAULT_NCS_DEVICE_ID_IMEI
4139
bool "Use IMEI as Memfault device ID"
42-
select HW_ID_LIBRARY
40+
select DEPRECATED
4341
help
44-
Use the device's IMEI as Memfault device ID
42+
Use the device's IMEI as Memfault device ID. Deprecated, use MEMFAULT_NCS_DEVICE_ID_HW_ID
43+
and HW_ID_LIBRARY_SOURCE_IMEI instead.
4544

46-
config MEMFAULT_NCS_DEVICE_ID_NET_MAC
47-
bool "Use network interface MAC address as device ID"
45+
config MEMFAULT_NCS_DEVICE_ID_HW_ID
46+
bool "Use hw_id for Memfault Device ID"
4847
select HW_ID_LIBRARY
4948
help
50-
Use the device's network interface MAC address as Memfault device ID
49+
Helper symbol to use hw_id API for Memfault Device ID if a corresponding option is selected.
5150

5251
config MEMFAULT_NCS_DEVICE_ID_STATIC
5352
bool "Set Memfault device ID in Kconfig"
@@ -274,23 +273,27 @@ choice MEMFAULT_HTTP_PERIODIC_UPLOAD_CONTEXT
274273
default MEMFAULT_HTTP_PERIODIC_UPLOAD_USE_DEDICATED_WORKQUEUE
275274
endchoice
276275

277-
# Workaround to select the correct HW ID source
276+
# Workaround to select the correct HW ID source choice config defaults
278277

279-
if HW_ID_LIBRARY
278+
if MEMFAULT_NCS_DEVICE_ID_HW_ID || MEMFAULT_NCS_DEVICE_ID_IMEI
280279

281280
choice HW_ID_LIBRARY_SOURCE
282-
default HW_ID_LIBRARY_SOURCE_IMEI if MEMFAULT_NCS_DEVICE_ID_IMEI
283-
default HW_ID_LIBRARY_SOURCE_NET_MAC if MEMFAULT_NCS_DEVICE_ID_NET_MAC
281+
default HW_ID_LIBRARY_SOURCE_IMEI if MEMFAULT_NCS_DEVICE_ID_IMEI || NRF_MODEM_LIB
282+
default HW_ID_LIBRARY_SOURCE_NET_MAC if BOARD_NRF7002DK_NRF5340_CPUAPP
283+
default HW_ID_LIBRARY_SOURCE_BLE_MAC if BT
284284

285285
config HW_ID_LIBRARY_SOURCE_IMEI
286286
bool "IMEI"
287287

288288
config HW_ID_LIBRARY_SOURCE_NET_MAC
289289
bool "Network interface MAC address"
290290

291+
config HW_ID_LIBRARY_SOURCE_BLE_MAC
292+
bool "BLE MAC address"
293+
291294
endchoice # HW_ID_LIBRARY_SOURCE
292295

293-
endif # HW_ID_LIBRARY
296+
endif # MEMFAULT_NCS_DEVICE_ID_HW_ID || MEMFAULT_NCS_DEVICE_ID_IMEI
294297

295298
module = MEMFAULT_NCS
296299
module-dep = LOG

modules/memfault-firmware-sdk/memfault_integration.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ BUILD_ASSERT(sizeof(CONFIG_MEMFAULT_NCS_FW_VERSION_STATIC) > 1,
6262
"Firmware version must be configured");
6363
#endif
6464

65-
#if defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI) || defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_NET_MAC)
65+
#if defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_HW_ID) || defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI)
6666
static char device_serial[HW_ID_LEN + 1];
6767
#elif defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_STATIC)
6868
BUILD_ASSERT(sizeof(CONFIG_MEMFAULT_NCS_DEVICE_ID) > 1,
@@ -128,7 +128,7 @@ int memfault_ncs_device_id_set(const char *device_id, size_t len)
128128
}
129129
#endif /* defined(CONFIG_MEMFAULT_DEVICE_INFO_BUILTIN) */
130130

131-
#if defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI) || defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_NET_MAC)
131+
#if defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_HW_ID) || defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI)
132132
static int device_info_init(void)
133133
{
134134
int err;
@@ -148,7 +148,8 @@ static int device_info_init(void)
148148

149149
return err;
150150
}
151-
#endif /* CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI || defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_NET_MAC) */
151+
#endif
152+
/* defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_HW_ID) || defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI) */
152153

153154
static int init(void)
154155
{
@@ -166,12 +167,12 @@ static int init(void)
166167
}
167168
}
168169

169-
#if defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI) || defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_NET_MAC)
170+
#if defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_HW_ID) || defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI)
170171
err = device_info_init();
171172
if (err) {
172173
LOG_ERR("Device info initialization failed, error: %d", err);
173174
}
174-
#endif /* CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI || CONFIG_MEMFAULT_NCS_DEVICE_ID_NET_MAC */
175+
#endif /* defined(CONFIG_MEMFAULT_NCS_DEVICE_ID_NET_MAC) */
175176

176177
if (IS_ENABLED(CONFIG_MEMFAULT_NCS_USE_DEFAULT_METRICS)) {
177178
memfault_ncs_metrics_init();

samples/bluetooth/peripheral_mds/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ CONFIG_MEMFAULT_LOGGING_ENABLE=y
4141
CONFIG_MEMFAULT_LOG_LEVEL_INF=y
4242

4343
CONFIG_MEMFAULT_NCS_PROJECT_KEY=""
44-
CONFIG_MEMFAULT_NCS_DEVICE_ID="nrf-ble-testdevice"
4544

4645
CONFIG_MEMFAULT_NCS_BT_METRICS=y
4746

samples/cellular/modem_shell/overlay-memfault.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD=y
1212
CONFIG_MEMFAULT_NCS_LTE_METRICS=y
1313
CONFIG_MEMFAULT_LOGGING_ENABLE=y
1414
CONFIG_MEMFAULT_LOG_LEVEL_DBG=y
15-
CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI=y
1615

1716
# Add to pick up support for sending Memfault data over HTTP
1817
CONFIG_MEMFAULT_HTTP_ENABLE=y

samples/debug/memfault/boards/nrf9151dk_nrf9151_ns.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ CONFIG_MEMFAULT_NCS_LTE_METRICS=y
1313
CONFIG_MEMFAULT_NCS_POST_COREDUMP_ON_NETWORK_CONNECTED=y
1414
CONFIG_LTE_LC_EDRX_MODULE=y
1515
CONFIG_LTE_LC_PSM_MODULE=y
16-
CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI=y
1716
CONFIG_MODEM_INFO=y
1817

1918
# Certificate management

samples/debug/memfault/boards/thingy91x_nrf9151_ns.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ CONFIG_MEMFAULT_NCS_POST_COREDUMP_ON_NETWORK_CONNECTED=y
1414
CONFIG_LTE_LC_EDRX_MODULE=y
1515
CONFIG_LTE_LC_PSM_MODULE=y
1616

17-
CONFIG_MEMFAULT_NCS_DEVICE_ID_IMEI=y
1817
CONFIG_MODEM_INFO=y
1918

2019
# Certificate management

0 commit comments

Comments
 (0)