Skip to content

Commit b7d5c1c

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.8.1 (Build 7582)
1 parent 4cbf8f4 commit b7d5c1c

30 files changed

+668
-28
lines changed

CHANGELOG.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,64 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to
77
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [1.8.1] - 2024-04-24
10+
11+
### :chart_with_upwards_trend: Improvements
12+
13+
- General:
14+
15+
- A new platform function, `memfault_platform_metrics_connectivity_boot()`,
16+
can be enabled to be called from the Memfault SDK `metrics_boot()` function
17+
after the metrics subsystem is initialized. This platform function is used
18+
for setting any initial state information for Connectivity metrics, and has
19+
default implementations for ESP-IDF (WiFi) and nRF9160 (LTE) devices.
20+
21+
- ESP-IDF:
22+
23+
- Add a new Kconfig setting,
24+
`CONFIG_MEMFAULT_COREDUMP_STORAGE_WRITE_OFFSET_SECTORS`, which can be used
25+
to set an offset into the coredump storage area where coredumps are written.
26+
The full partition will still be erased, but coredumps will be written
27+
starting at the sector offset selected with this setting. The skipped sector
28+
will remain at the erased value, `0xff` for all bytes.
29+
30+
- Zephyr:
31+
32+
- Added a built-in weakly defined implementation of
33+
`memfault_platform_get_device_info()`, which provides:
34+
35+
- `.device_serial` : A default device serial based on the SOC's unique ID
36+
registers, via the
37+
[`hwinfo` subsystem](https://docs.zephyrproject.org/3.6.0/hardware/peripherals/hwinfo.html).
38+
This is the default device serial when `CONFIG_HWINFO=y`. If
39+
`CONFIG_HWINFO=n`, the fallback device serial is
40+
`CONFIG_SOC "-testserial"`.
41+
- `.software_type` : Configurable with
42+
`CONFIG_MEMFAULT_BUILTIN_DEVICE_INFO_SOFTWARE_TYPE`, defaults to `"app"`
43+
- `.software_version` : Configurable with
44+
`CONFIG_MEMFAULT_BUILTIN_DEVICE_INFO_SOFTWARE_VERSION`. Defaults to an
45+
identifier based on the `VERSION` file in the application, using the
46+
Zephyr
47+
[Application Version](https://docs.zephyrproject.org/3.6.0/build/version/index.html)
48+
feature, or `"0.0.0"` if unavailable.
49+
- `.hardware_version` : Configurable with
50+
`CONFIG_MEMFAULT_BUILTIN_DEVICE_INFO_HARDWARE_VERSION`. Defaults to an
51+
identifier based on `CONFIG_BOARD` and `CONFIG_BOARD_REVISION` (if set).
52+
53+
- Add a new Zephyr example app for the
54+
[ST NUCLEO-WBA55CG board](https://docs.zephyrproject.org/3.6.0/boards/st/nucleo_wba55cg/doc/nucleo_wba55cg.html),
55+
under [`examples/zephyr/nucleo_wba55cg`](examples/zephyr/nucleo_wba55cg).
56+
This example demonstrates the Memfault SDK integration on the NUCLEO-WBA55CG
57+
board.
58+
59+
- nRF-Connect SDK:
60+
61+
- Add [Connected Time Vital](https://mflt.io/connectivity-metrics)
62+
out-of-the-box for nRF9160 projects, tracking modem connected time. This is
63+
controlled with the Kconfig
64+
`CONFIG_MEMFAULT_NRF_CONNECTIVITY_CONNECTED_TIME_NRF91X`, enabled by
65+
default.
66+
967
## [1.8.0] - 2024-04-17
1068

1169
### :chart_with_upwards_trend: Improvements

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
BUILD ID: 7456
2-
GIT COMMIT: 69ebc0be9a
3-
VERSION: 1.8.0
1+
BUILD ID: 7582
2+
GIT COMMIT: ece044b45b
3+
VERSION: 1.8.1

components/include/memfault/core/reboot_reason_types.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ typedef enum MfltResetReason {
108108
// executing from a fault handler.
109109
kMfltRebootReason_Lockup = 0x9401,
110110

111+
// A reset triggered due to a security violation
112+
kMfltRebootReason_SecurityViolation = 0x9402,
113+
114+
// A reset triggered due to a parity error (i.e. memory integrity check)
115+
kMfltRebootReason_ParityError = 0x9403,
116+
117+
// A reset triggered due to a temperature error
118+
kMfltRebootReason_Temperature = 0x9404,
119+
120+
// A reset due to some other hardware error
121+
kMfltRebootReason_Hardware = 0x9405,
122+
111123
//
112124
// User Defined Unexpected Resets
113125
//

components/include/memfault/default_config.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,16 @@ extern "C" {
653653
#define MEMFAULT_PLATFORM_FREERTOS_TCB_SIZE 100
654654
#endif
655655

656+
//
657+
// Platform-specific metrics configuration options
658+
//
659+
660+
//! Enable this flag to cause metrics_boot() to call a platform-implemented
661+
//! memfault_platform_metrics_connectivity_boot() function
662+
#ifndef MEMFAULT_PLATFORM_METRICS_CONNECTIVITY_BOOT
663+
#define MEMFAULT_PLATFORM_METRICS_CONNECTIVITY_BOOT 0
664+
#endif
665+
656666
#ifdef __cplusplus
657667
}
658668
#endif
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#pragma once
2+
3+
//! @file
4+
//!
5+
//! Copyright (c) Memfault, Inc.
6+
//! See License.txt for details
7+
//!
8+
//! Copyright (c) Memfault, Inc.
9+
//! See License.txt for details
10+
//!
11+
//! @brief
12+
//! Optional platform-specific boot function for initializing connectivity metrics.
13+
14+
#include <stdbool.h>
15+
#include <stdint.h>
16+
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
//! The platform must implement this function. It is called during boot to initialize
22+
//! platform-specific connectivity metrics.
23+
//!
24+
//! For example, this function may register handlers for connectivity events, which when
25+
//! received, the handlers will mark the begin and end of connection periods.
26+
void memfault_platform_metrics_connectivity_boot(void);
27+
28+
#ifdef __cplusplus
29+
}
30+
#endif

components/include/memfault/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ typedef struct {
1919
uint8_t patch;
2020
} sMfltSdkVersion;
2121

22-
#define MEMFAULT_SDK_VERSION { .major = 1, .minor = 8, .patch = 0 }
23-
#define MEMFAULT_SDK_VERSION_STR "1.8.0"
22+
#define MEMFAULT_SDK_VERSION { .major = 1, .minor = 8, .patch = 1 }
23+
#define MEMFAULT_SDK_VERSION_STR "1.8.1"
2424

2525
#ifdef __cplusplus
2626
}

components/metrics/src/memfault_metrics.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "memfault/core/serializer_helper.h"
2121
#include "memfault/metrics/battery.h"
2222
#include "memfault/metrics/metrics.h"
23+
#include "memfault/metrics/platform/connectivity.h"
2324
#include "memfault/metrics/platform/overrides.h"
2425
#include "memfault/metrics/platform/timer.h"
2526
#include "memfault/metrics/reliability.h"
@@ -1272,5 +1273,9 @@ int memfault_metrics_boot(const sMemfaultEventStorageImpl *storage_impl,
12721273
return rv;
12731274
}
12741275

1276+
#if MEMFAULT_PLATFORM_METRICS_CONNECTIVITY_BOOT
1277+
memfault_platform_metrics_connectivity_boot();
1278+
#endif
1279+
12751280
return 0;
12761281
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.west
2+
/bootloader
3+
/build
4+
/modules
5+
/tools
6+
/zephyr
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Memfault Zephyr `nucleo_wba55cg` Example Application
2+
3+
This folder contains an example integration of the Memfault SDK using the port
4+
provided in `ports/zephyr`
5+
6+
The demo was tested using the
7+
[ST NUCLEO-WBA55CG board](https://docs.zephyrproject.org/3.6.0/boards/st/nucleo_wba55cg/doc/nucleo_wba55cg.html).
8+
9+
### Prerequisite
10+
11+
We assume you already have a working Zephyr toolchain installed locally.
12+
Step-by-step instructions can be found in the
13+
[Zephyr Documentation](https://docs.zephyrproject.org/2.5.0/getting_started/index.html#build-hello-world).
14+
15+
### Setup
16+
17+
From a Zephyr-enabled shell environment (`west` tool is available), initialize
18+
the workspace:
19+
20+
```bash
21+
west init -l memfault_demo_app
22+
west update
23+
west blobs fetch stm32
24+
```
25+
26+
### Building
27+
28+
```bash
29+
west build --board nucleo_wba55cg memfault_demo_app
30+
[...]
31+
[271/271] Linking C executable zephyr/zephyr.elf
32+
```
33+
34+
### Flashing
35+
36+
The build can be flashed on the development board using `west flash` ( See
37+
Zephyr
38+
["Building, Flashing, & Debugging" documentation](https://docs.zephyrproject.org/3.6.0/guides/west/build-flash-debug.html?highlight=building%20flashing#flashing-west-flash))
39+
40+
The default runner is `STM32_Programmer_CLI`, which must be available on `PATH`
41+
when running `west flash`. `STM32_Programmer_CLI` is installed
42+
[standalone](https://www.st.com/en/development-tools/stm32cubeprog.html) or from
43+
the STM32CubeIDE installation.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.13.1)
2+
3+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
4+
project(memfault_demo_app)
5+
6+
zephyr_include_directories(config)
7+
target_sources(app PRIVATE src/main.c)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VERSION_MAJOR = 0
2+
VERSION_MINOR = 0
3+
PATCHLEVEL = 1
4+
VERSION_TWEAK = 0
5+
EXTRAVERSION =
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Define custom system metrics to track. See https://mflt.io/embedded-metrics.
2+
// For example:
3+
//
4+
// MEMFAULT_METRICS_KEY_DEFINE(main_task_stack_hwm, kMemfaultMetricType_Unsigned)
5+
// MEMFAULT_METRICS_KEY_DEFINE(ble_min_rssi, kMemfaultMetricType_Signed)
6+
// MEMFAULT_METRICS_KEY_DEFINE(mcu_sleep_time_ms, kMemfaultMetricType_Timer)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
//! @file
4+
//!
5+
//! Copyright (c) Memfault, Inc.
6+
//! See License.txt for details
7+
//!
8+
//! Platform overrides for the default configuration settings in the memfault-firmware-sdk.
9+
//! Default configuration settings can be found in "memfault/config.h"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//! Define custom error reasons that can be filtered & searched
2+
//! on in the Memfault UI, i.e
3+
//! MEMFAULT_TRACE_REASON_DEFINE(critical_error)
4+
//! See documentation here: https://mflt.io/error-tracing
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# General config
2+
CONFIG_SHELL=y
3+
4+
CONFIG_LOG=y
5+
# CONFIG_LOG_BACKEND_UART=y ensures logs (and printk's, because of
6+
# CONFIG_LOG_PRINTK=y) are available before the console thread is started.
7+
CONFIG_LOG_BACKEND_UART=y
8+
# Logs are going to the UART directly, don't need to also emit them to the shell
9+
CONFIG_SHELL_LOG_BACKEND=n
10+
CONFIG_LOG_MODE_IMMEDIATE=y
11+
12+
# To catch stack overflows at the point of overflow
13+
CONFIG_MPU_STACK_GUARD=y
14+
15+
# Memfault configuration
16+
CONFIG_MEMFAULT=y
17+
CONFIG_MEMFAULT_LOGGING_ENABLE=y
18+
19+
# Enable asserts, now that Memfault is enabled to catch crashes
20+
CONFIG_ASSERT=y
21+
22+
# Enabling hwinfo gives us a unique device identifier. See
23+
# ports/zephyr/common/memfault_platform_core.c for details
24+
CONFIG_HWINFO=y
25+
26+
CONFIG_BT=y
27+
CONFIG_LOG=y
28+
CONFIG_BT_SMP=y
29+
CONFIG_BT_PERIPHERAL=y
30+
CONFIG_BT_DIS=y
31+
CONFIG_BT_DIS_PNP=n
32+
CONFIG_BT_BAS=y
33+
CONFIG_BT_HRS=y
34+
CONFIG_BT_DEVICE_NAME="Memfault Sample App"
35+
CONFIG_BT_DEVICE_APPEARANCE=833
36+
37+
CONFIG_BT_SHELL=y
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//! @file
2+
//!
3+
//! Copyright (c) Memfault, Inc.
4+
//! See License.txt for details
5+
6+
#include <string.h>
7+
#include <zephyr/devicetree.h>
8+
#include <zephyr/drivers/gpio.h>
9+
#include <zephyr/kernel.h>
10+
#include <zephyr/logging/log.h>
11+
12+
#include "memfault/components.h"
13+
#include "memfault/ports/zephyr/http.h"
14+
15+
LOG_MODULE_REGISTER(mflt_app, LOG_LEVEL_DBG);
16+
17+
// Blink code taken from the zephyr/samples/basic/blinky example.
18+
19+
static void blink_forever(void) {
20+
/* 1000 msec = 1 sec */
21+
#define SLEEP_TIME_MS 1000
22+
23+
/* The devicetree node identifier for the "led0" alias. */
24+
#define LED0_NODE DT_ALIAS(led0)
25+
26+
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
27+
28+
int ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
29+
if (ret < 0) {
30+
return;
31+
}
32+
33+
while (1) {
34+
gpio_pin_toggle_dt(&led);
35+
k_msleep(SLEEP_TIME_MS);
36+
}
37+
}
38+
39+
// put the blink_forever in its own thread.
40+
K_THREAD_DEFINE(blink_forever_thread, 1024, blink_forever, NULL, NULL, NULL, K_PRIO_PREEMPT(8), 0,
41+
0);
42+
43+
int main(void) {
44+
printk(MEMFAULT_BANNER_COLORIZED "\n");
45+
46+
LOG_INF("Memfault Demo App! Board %s\n", CONFIG_BOARD);
47+
memfault_device_info_dump();
48+
49+
return 0;
50+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# West manifest for Memfault Example Application
2+
3+
manifest:
4+
5+
remotes:
6+
- name: zephyrproject-rtos
7+
url-base: https://github.com/zephyrproject-rtos
8+
9+
projects:
10+
- name: zephyr
11+
remote: zephyrproject-rtos
12+
revision: v3.6.0
13+
import:
14+
# Limit the Zephyr modules to the required set
15+
name-allowlist:
16+
- cmsis
17+
- hal_stm32
18+
- picolibc
19+
- tinycrypt
20+
21+
- name: memfault-firmware-sdk
22+
path: modules/lib/memfault-firmware-sdk
23+
url: https://github.com/memfault/memfault-firmware-sdk
24+
# Memfault recommends pinning to a specific release tag for production
25+
revision: master

examples/zephyr/qemu/qemu-app/src/cdr.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ static const char cdr_payload[] = "hello cdr!";
3333

3434
// the CDR metadata structure
3535
static sMemfaultCdrMetadata s_cdr_metadata = {
36-
.start_time =
37-
{
38-
.type = kMemfaultCurrentTimeType_Unknown,
39-
},
36+
.start_time = {
37+
.type = kMemfaultCurrentTimeType_Unknown,
38+
},
4039
.mimetypes = mimetypes,
4140
.num_mimetypes = MEMFAULT_ARRAY_SIZE(mimetypes),
4241

0 commit comments

Comments
 (0)