Skip to main content

Reference: memfaultd CLI

Useful links:

Basic Usage

Running memfaultd --help prints the following:

Usage: memfaultd [OPTION]...

--config-file <file> : Configuration file
--daemonize : Daemonize process
--enable-data-collection : Enable data collection, will restart the main memfaultd service
--disable-data-collection : Disable data collection, will restart the main memfaultd service
-h, --help : Display this help and exit
-s, --show-settings : Show settings
-v, --version : Show version information

The --config-file path defaults to /etc/memfaultd.conf. The settings you add in /etc/memfaultd.conf extend the built-in configuration file.

Sample output from memfaultd --show-settings

Base configuration (/etc/memfaultd.conf):
{ "queue_size_kib": 1024, "data_dir": "\/media\/memfaultd", "refresh_interval_seconds": 3600, "enable_data_collection": false, "swupdate_plugin": { "input_file": "\/etc\/swupdate.cfg", "output_file": "\/tmp\/swupdate.cfg" }, "reboot_plugin": { "uboot_fw_env_file": "\/etc\/fw_env.config" }, "collectd_plugin": { "footer_include_output_file": "/tmp/collectd-footer-include.conf", "header_include_output_file": "/tmp/collectd-header-include.conf", "interval_seconds": 3600, "non_memfaultd_chain": "", "write_http_buffer_size_kib": 64 }, "coredump_plugin": { "coredump_max_size_kib": 96000, "rate_limit_count": 5, "rate_limit_duration_seconds": 3600, "storage_max_usage_kib": 0, "storage_min_headroom_kib": 10240 } }

Runtime configuration:
{ "enable_data_collection": true }

Device configuration from memfault-device-info:
MEMFAULT_DEVICE_ID=some-device-a466-4ad8-8eeb-6234ad623449
MEMFAULT_SOFTWARE_VERSION=1.0.0
MEMFAULT_SOFTWARE_TYPE=main
MEMFAULT_HARDWARE_VERSION=prod
MEMFAULT_BASE_URL=https://device.memfault.com
MEMFAULT_PROJECT_KEY=<YOUR_PROJECT_KEY>

Plugin enabled:
reboot
swupdate
collectd
coredump

Note that plugins can be opted out of at build time.

Usage in a systemd service

tip

The meta-memfault Yocto layer already includes a service file, so you don't need to add one if you're using meta-memfault.

You can use the --daemonize flag for this. See this example, taken from the meta-memfault layer:

[Unit]
Description=memfaultd daemon
After=local-fs.target network.target
Before=swupdate.service collectd.service

[Service]
Type=forking
PIDFile=/run/memfaultd.pid
ExecStart=/usr/bin/memfaultd --daemonize
Restart=on-failure

[Install]
WantedBy=multi-user.target

The Before= parameter is there to ensure memfaultd starts before swupdate.service as well as collectd.service. The configuration files used by these daemons are generated (at least partly) by memfaultd at startup, and need to be present before the respective services start.

If you're not using OTA or Metrics, you may remove the corresponding part of the Before= parameter. You may also wish to opt out of building the plugins with memfaultd.