Memfault¶
The Memfault module provides an integration of Memfault SDK into nRF Connect SDK and expands the functionality of the SDK with some options that are specific to nRF Connect SDK.
Overview¶
Memfault SDK is an SDK for embedded devices to make use of services that Memfault offers on their platform.
The SDK provides a functionality to collect debug information from devices in the form of coredumps, error traces, metrics, logs and more. Information that is collected from the device can be sent to Memfault’s cloud solution for further analysis. Communication with the Memfault Cloud is handled by APIs available in Memfault SDK, while the integration code of the SDK in nRF Connect SDK provides some additional functionality.
For official documentation for Memfault SDK and the Memfault platform in general, see Memfault Docs.
See the nRF9160: Memfault sample for an example of Memfault implementation in nRF Connect SDK.
Memfault in nRF Connect SDK currently supports the nRF9160-based build targets.
Using Memfault SDK¶
The SDK is part of the West manifest in nRF Connect SDK and is automatically downloaded when running west update
.
By default, it is downloaded to <nRF Connect SDK path>/modules/lib/memfault-firmware-sdk/
.
To include Memfault in your build, enable the Kconfig option CONFIG_MEMFAULT
.
The APIs in Memfault SDK can then be linked into your application.
In addition, you must configure a Memfault project key using CONFIG_MEMFAULT_NCS_PROJECT_KEY
.
Configuration¶
In general, configuration of Memfault SDK in nRF Connect SDK is done using Kconfig options.
Kconfig options are defined both in Memfault SDK and in the integration layer, which integrates the SDK into nRF Connect SDK.
Kconfig options of the integration layer are located in modules/memfault/Kconfig
.
These Kconfig options are differentiated by two distinct prefixes:
CONFIG_MEMFAULT_
- Prefix for options defined in Memfault SDKCONFIG_MEMFAULT_NCS_
- Prefix for options defined in nRF Connect SDK
Configuration files¶
Memfault SDK requires the following three files in the include path during the build process:
memfault_platform_config.h
- Sets Memfault SDK configurations that are not covered by Kconfig optionsmemfault_metrics_heartbeat_config.def
- Defines application-specific metricsmemfault_trace_reason_user_config.def
- Defines application-specific trace reasons
These configuration files are added to the include path by adding the following in CMakeLists.txt
:
zephyr_include_directories(config)
Configuration options in Memfault SDK¶
Following are some of the configuration options that Memfault SDK define:
You can find more details on each option using menuconfig
, guiconfig
, and in the Kconfig sources in modules/lib/memfault-firmware-sdk/ports/zephyr/Kconfig
.
Note
The Memfault shell is enabled by default, using the UART interface.
If AT Host library and the memfault module are enabled simultaneously, both will not behave as expected, as they both require the UART same interface.
Therefore, it is recommended to only enable one of these at the same time.
To disable the Memfault shell, you need to disable the two configurations, CONFIG_MEMFAULT_SHELL
and CONFIG_MEMFAULT_NRF_SHELL
.
Configuration options in nRF Connect SDK¶
The Kconfig options for Memfault that are defined in nRF Connect SDK provide some additional features compared to the options that are already implemented in Memfault SDK:
The nRF Connect SDK integration of Memfault SDK provides default values for some metadata that are required to identify the firmware when it is sent to Memfault cloud. These defaults can be controlled by using the configuration options below:
API documentation¶
include/memfault_ncs.h
modules/memfault/
-
group
memfault_ncs
Convenience functions for using Memfault firmware SDK with nRF Connect SDK.
Functions
-
int
memfault_ncs_device_id_set
(const char *device_id, size_t len)¶ Set the Memfault device ID.
Note
In order to use this API successfully, CONFIG_MEMFAULT_NCS_DEVICE_ID_RUNTIME must be enabled.
- Parameters
device_id – Pointer to device ID buffer
len – Length of device ID. Can not exceed CONFIG_MEMFAULT_NCS_DEVICE_ID_MAX_LEN.
- Returns
0 on success, otherwise a negative error code
-
int