Skip to content

Commit 8cd5dc1

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.5.0 (Build 4793)
1 parent 9679e65 commit 8cd5dc1

File tree

91 files changed

+2988
-570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2988
-570
lines changed

CHANGELOG.md

Lines changed: 132 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,124 @@
11
# Memfault Firmware SDK Changelog
22

3+
## [1.5.0] - 2023-11-29
4+
5+
### :rocket: New Features
6+
7+
- General:
8+
9+
- Added support for Session Metrics. These are similar to Heartbeat Metrics,
10+
except they are set on an arbitrary session interval (not required to be
11+
aligned to Heartbeat interval). Session metrics are useful for tracking
12+
device operation sessions- for example, measuring properties for a BLE
13+
connected stove top during a single cooking session. Session metrics
14+
automatically include a "session duration" timer metric.
15+
16+
Session metrics must be defined using the new session-specific APIs, but are
17+
set using the same `MEMFAULT_METRIC_SET_*` APIs as Heartbeat metrics.
18+
19+
See the
20+
[`metrics.h` header file](components/include/memfault/metrics/metrics.h) for
21+
usage details.
22+
23+
- New built in metrics for measuring the following properties:
24+
25+
- **crash-free hours**: enabled by default, generates `operational_hours`
26+
and `operational_crashfree_hours` metrics, which are automatically
27+
processed by Memfault
28+
29+
- **battery drop**: enabled with `#define MEMFAULT_METRICS_BATTERY_ENABLE 1`
30+
in `memfault_platform_config.h`. See more information in the
31+
[header file](components/include/memfault/metrics/battery.h) for how to
32+
use the metric.
33+
34+
- **connectivity**: enabled with
35+
`MEMFAULT_METRICS_SYNC_SUCCESS`/`MEMFAULT_METRICS_MEMFAULT_SYNC_SUCCESS`/`MEMFAULT_METRICS_CONNECTIVITY_CONNECTED_TIME`.
36+
See more information in the
37+
[header file](components/include/memfault/metrics/connectivity.h) for how
38+
to use the metric.
39+
40+
These metrics are considered first-class metrics by Memfault, are exempt
41+
from quota limits, and are automatically processed by Memfault.
42+
43+
- Zephyr:
44+
45+
- By default, set the `sync_memfault_successful`/`sync_memfault_failure`
46+
metrics for devices using Memfault's Zephyr HTTP chunk upload functionality.
47+
This feature is controlled with the `CONFIG_MEMFAULT_SYNC_MEMFAULT_METRICS`
48+
Kconfig flag.
49+
50+
- Automatically set captured timestamps for events for devices that either
51+
implement the RTC subsystem, or use the Nordic `date_time` library. The
52+
appropriate option is enabled by default based on which features are
53+
available, and can be controlled with the Kconfig flags:
54+
`CONFIG_MEMFAULT_SYSTEM_TIME_SOURCE_DATETIME` or
55+
`CONFIG_MEMFAULT_SYSTEM_TIME_SOURCE_RTC`.
56+
57+
- ESP-IDF:
58+
59+
- By default, set the `sync_memfault_successful`/`sync_memfault_failure`
60+
metrics for devices using Memfault's ESP-IDF HTTP chunk upload
61+
functionality. This feature is controlled with the
62+
`CONFIG_MEMFAULT_SYNC_MEMFAULT_METRICS` Kconfig flag.
63+
64+
### :chart_with_upwards_trend: Improvements
65+
66+
- General:
67+
68+
- Add the ability to extend the Memfault Demo Shell command table with custom
69+
commands. This is used in the [`examples/freertos`](examples/freertos) demo
70+
project to add 2 new commands:
71+
72+
- `freertos_tasks` : print FreeRTOS task information, via `vTaskList()`
73+
- `freertos_vassert` : trigger a `vAssertCalled` FreeRTOS assert, via
74+
`configASSERT()`
75+
76+
The Shell extension API is documented in
77+
[`components/include/memfault/demo/shell_commands.h`](components/include/memfault/demo/shell_commands.h),
78+
and must be enabled by setting
79+
`#define MEMFAULT_DEMO_SHELL_COMMAND_EXTENSIONS 1` in
80+
`memfault_platform_config.h`.
81+
82+
- Zephyr:
83+
84+
- Remove a warning in Zephyr 3.5+ where the `zephyr/random/rand32.h` header
85+
was renamed to `zephyr/random/random.h`. This was reported in
86+
[#66](https://github.com/memfault/memfault-firmware-sdk/issues/66)- thanks
87+
to @nordicjm for reporting this!
88+
89+
- Add test commands for exercising Secure Faults in ARM TrustZone-enabled
90+
chips:
91+
92+
- `mflt test badptr`
93+
- `mflt test isr_badptr`
94+
95+
Note that non-TrustZone chips may not trigger a fault when running those
96+
commands.
97+
98+
- nRF-Connect SDK:
99+
100+
- Add the `CONFIG_AT_SHELL` setting to the
101+
[`examples/nrf-connect-sdk/nrf9160`](nrf-connect-sdk/nrf9160) sample app.
102+
This permits sending raw AT commands, useful for testing.
103+
104+
- Specific to nRF-Connect based apps using FOTA, add a warning if
105+
`CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE > 1024`, which can sporadically error
106+
out on nRF9160 devices (there is a limitation in the modem, see
107+
`CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_2048=y`) and DevZone note
108+
[here](https://devzone.nordicsemi.com/f/nordic-q-a/68601/tls-2303-bytes-packet-limit/281107).
109+
110+
- Improve FOTA support for nRF-Connect SDK 2.4+, by improving the technique
111+
used to find the correct Memfault server root cert. Memfault uses a fast CDN
112+
to improve OTA payload delivery, which uses a different root cert than the
113+
Memfault device server. Please contact [email protected] immediately if
114+
you encounter any cert-related issues.
115+
116+
### :boom: Breaking Changes
117+
118+
- The metrics convenience API added in v1.4.3 (`MEMFAULT_HEARTBEAT_SET_*` and
119+
others) have been renamed to `MEMFAULT_METRIC_SET_*`, to better support the
120+
new Session Metric feature.
121+
3122
## [1.4.4] - 2023-11-13
4123

5124
### :chart_with_upwards_trend: Improvements
@@ -19,7 +138,7 @@
19138
with `0` bytes loaded into the output buffer and `*buf_len` set to `0`.
20139

21140
- Update all example Metrics implementations to use the new API from v1.4.3
22-
(eg `MEMFAULT_HEARTBEAT_SET_UNSIGNED` instead of
141+
(eg `MEMFAULT_METRIC_SET_UNSIGNED` instead of
23142
`memfault_metrics_heartbeat_set_unsigned`).
24143

25144
- Fix compilation for systems not integrating the
@@ -34,12 +153,12 @@
34153

35154
- Add a new streamlined Metrics setter API:
36155

37-
- `MEMFAULT_HEARTBEAT_SET_SIGNED(key_name, signed_value)`
38-
- `MEMFAULT_HEARTBEAT_SET_UNSIGNED(key_name, unsigned_value)`
39-
- `MEMFAULT_HEARTBEAT_SET_STRING(key_name, value)`
40-
- `MEMFAULT_HEARTBEAT_TIMER_START(key_name)`
41-
- `MEMFAULT_HEARTBEAT_TIMER_STOP(key_name)`
42-
- `MEMFAULT_HEARTBEAT_ADD(key_name, amount)`
156+
- `MEMFAULT_METRIC_SET_SIGNED(key_name, signed_value)`
157+
- `MEMFAULT_METRIC_SET_UNSIGNED(key_name, unsigned_value)`
158+
- `MEMFAULT_METRIC_SET_STRING(key_name, value)`
159+
- `MEMFAULT_METRIC_TIMER_START(key_name)`
160+
- `MEMFAULT_METRIC_TIMER_STOP(key_name)`
161+
- `MEMFAULT_METRIC_ADD(key_name, amount)`
43162

44163
These APIs can be used in place of the original APIs:
45164

@@ -71,6 +190,12 @@
71190
- Add a new out-of-box metric, `wifi_ap_oui`, which will record the associated
72191
AP's Organizationally Unique Identifier (OUI) in the Memfault heartbeat.
73192

193+
- Zephyr:
194+
195+
- Organize the Memfault Coredump Kconfig settings under a
196+
`Memfault Coredump Settings` submenu, for easier navigation when using
197+
graphical Kconfig frontends like menuconfig.
198+
74199
### :chart_with_upwards_trend: Improvements
75200

76201
- General:

License.txt

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
1-
Copyright (c) 2019 - Present, Memfault
2-
All rights reserved.
3-
4-
Redistribution and use in source and binary forms, with or without
5-
modification, are permitted provided that the following conditions are met:
6-
7-
1. Redistributions of source code or in binary form must reproduce
8-
the above copyright notice, this list of conditions and the following
9-
disclaimer in the documentation and/or other materials provided with the
10-
distribution.
11-
12-
2. Neither the name of Memfault nor the names of its contributors may be
13-
used to endorse or promote products derived from this software without
14-
specific prior written permission.
15-
16-
3. This software, with or without modification, must only be used with
17-
the Memfault services and integrated with the Memfault server.
18-
19-
4. Any software provided in binary form under this license must not be
20-
reverse engineered, decompiled, modified and/or disassembled.
21-
22-
THIS SOFTWARE IS PROVIDED BY MEMFAULT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
24-
NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25-
SHALL MEMFAULT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27-
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28-
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29-
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30-
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31-
THE POSSIBILITY OF SUCH DAMAGE.
32-
33-
1+
Copyright (c) 2019 - Present, Memfault
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code or in binary form must reproduce
8+
the above copyright notice, this list of conditions and the following
9+
disclaimer in the documentation and/or other materials provided with the
10+
distribution.
11+
12+
2. Neither the name of Memfault nor the names of its contributors may be
13+
used to endorse or promote products derived from this software without
14+
specific prior written permission.
15+
16+
3. This software, with or without modification, must only be used with
17+
the Memfault services and integrated with the Memfault server.
18+
19+
4. Any software provided in binary form under this license must not be
20+
reverse engineered, decompiled, modified and/or disassembled.
21+
22+
THIS SOFTWARE IS PROVIDED BY MEMFAULT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
24+
NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25+
SHALL MEMFAULT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28+
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31+
THE POSSIBILITY OF SUCH DAMAGE.

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
BUILD ID: 4488
2-
GIT COMMIT: 7744b8176
3-
VERSION: 1.4.4
1+
BUILD ID: 4793
2+
GIT COMMIT: 06d69b79b
3+
VERSION: 1.5.0

components/demo/src/memfault_demo_shell.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,33 @@
2020
#define MEMFAULT_SHELL_MAX_ARGS (16)
2121
#define MEMFAULT_SHELL_PROMPT "mflt> "
2222

23-
#define MEMFAULT_SHELL_FOR_EACH_COMMAND(command) \
24-
for (const sMemfaultShellCommand *command = g_memfault_shell_commands; \
25-
command < &g_memfault_shell_commands[g_memfault_num_shell_commands]; \
26-
++command)
23+
#if defined(MEMFAULT_DEMO_SHELL_COMMAND_EXTENSIONS)
24+
// When the extension list is enabled, iterate over both the core commands and
25+
// the extension commands. This construct, despite being pretty intricate,
26+
// saves about ~28 bytes of code space over running the iteration twice in a
27+
// row, and keeps the iterator in one macro, instead of two.
28+
#define MEMFAULT_SHELL_FOR_EACH_COMMAND(command) \
29+
const sMemfaultShellCommand *command = g_memfault_shell_commands; \
30+
for (size_t i = 0; i < g_memfault_num_shell_commands + s_mflt_shell.num_extension_commands; \
31+
++i, command = (i < g_memfault_num_shell_commands) \
32+
? &g_memfault_shell_commands[i] \
33+
: &s_mflt_shell.extension_commands[i - g_memfault_num_shell_commands])
34+
#else
35+
#define MEMFAULT_SHELL_FOR_EACH_COMMAND(command) \
36+
for (const sMemfaultShellCommand *command = g_memfault_shell_commands; \
37+
command < &g_memfault_shell_commands[g_memfault_num_shell_commands]; ++command)
38+
#endif
2739

2840
static struct MemfaultShellContext {
2941
int (*send_char)(char c);
3042
size_t rx_size;
3143
// the char we will ignore when received end-of-line sequences
3244
char eol_ignore_char;
3345
char rx_buffer[MEMFAULT_DEMO_SHELL_RX_BUFFER_SIZE];
46+
#if defined(MEMFAULT_DEMO_SHELL_COMMAND_EXTENSIONS)
47+
const sMemfaultShellCommand *extension_commands;
48+
size_t num_extension_commands;
49+
#endif
3450
} s_mflt_shell;
3551

3652
static bool prv_booted(void) {
@@ -137,6 +153,14 @@ void memfault_demo_shell_boot(const sMemfaultShellImpl *impl) {
137153
prv_echo_str("\n" MEMFAULT_SHELL_PROMPT);
138154
}
139155

156+
#if defined(MEMFAULT_DEMO_SHELL_COMMAND_EXTENSIONS)
157+
void memfault_shell_command_set_extensions(const sMemfaultShellCommand *const commands,
158+
size_t num_commands) {
159+
s_mflt_shell.extension_commands = commands;
160+
s_mflt_shell.num_extension_commands = num_commands;
161+
}
162+
#endif
163+
140164
//! Logic to deal with CR, LF, CRLF, or LFCR end-of-line (EOL) sequences
141165
//! @return true if the character should be ignored, false otherwise
142166
static bool prv_should_ignore_eol_char(char c) {

components/include/memfault/components.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "memfault/core/heap_stats.h"
2929
#include "memfault/core/log.h"
3030
#include "memfault/core/math.h"
31+
#include "memfault/core/platform/battery.h"
3132
#include "memfault/core/platform/core.h"
3233
#include "memfault/core/platform/crc32.h"
3334
#include "memfault/core/platform/debug_log.h"
@@ -49,9 +50,12 @@
4950
#include "memfault/http/platform/http_client.h"
5051
#include "memfault/http/root_certs.h"
5152
#include "memfault/http/utils.h"
53+
#include "memfault/metrics/battery.h"
54+
#include "memfault/metrics/connectivity.h"
5255
#include "memfault/metrics/metrics.h"
5356
#include "memfault/metrics/platform/overrides.h"
5457
#include "memfault/metrics/platform/timer.h"
58+
#include "memfault/metrics/reliability.h"
5559
#include "memfault/metrics/utils.h"
5660
#include "memfault/panics/assert.h"
5761
#include "memfault/panics/coredump.h"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#pragma once
2+
3+
//! @file
4+
//!
5+
//! Copyright (c) Memfault, Inc.
6+
//! See License.txt for details
7+
//!
8+
//! @brief
9+
//! Required dependency functions for the Memfault Battery Metrics component.
10+
11+
#include <stdbool.h>
12+
#include <stdint.h>
13+
14+
#ifdef __cplusplus
15+
extern "C" {
16+
#endif
17+
18+
//! The platform must implement this function. It provides the current battery
19+
//! state of charge in percent (0-100%).
20+
//!
21+
//! @returns the current battery state of charge in percent (0-100%)
22+
uint32_t memfault_platform_get_stateofcharge(void);
23+
24+
//! The platform must implement this function. The battery metrics
25+
//! implementation uses this to check if the battery is discharging.
26+
//!
27+
//! @return true if the system is discharging, false if it is not discharging
28+
bool memfault_platform_is_discharging(void);
29+
30+
#ifdef __cplusplus
31+
}
32+
#endif

components/include/memfault/core/reboot_reason_types.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ extern "C" {
1414

1515
typedef enum MfltResetReason {
1616
// A reboot reason was not determined either by hardware or a previously marked reboot reason
17-
// This reason is classified as an unexpected reboot when used by the built-in metric
18-
// MemfaultSdkMetric_UnexpectedRebootDidOccur
17+
// This reason is classified as a crash when calculating the operational_crashfree_hours metric
1918
kMfltRebootReason_Unknown = 0x0000,
2019

2120
//
@@ -70,6 +69,8 @@ typedef enum MfltResetReason {
7069

7170
// A software reset triggered due to a dynamic memory (heap) allocation failure.
7271
kMfltRebootReason_OutOfMemory = 0x800A,
72+
// A reset due to stack overflow
73+
kMfltRebootReason_StackOverflow = 0x800B,
7374

7475
// Resets from Arm Faults
7576
kMfltRebootReason_BusFault = 0x9100,

components/include/memfault/core/serializer_key_ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ typedef enum {
4141
//! EventInfo dictionary keys for events with type kMemfaultEventType_Heartbeat.
4242
typedef enum {
4343
kMemfaultHeartbeatInfoKey_Metrics = 1,
44+
kMemfaultHeartbeatInfoKey_Session = 2,
4445
} eMemfaultHeartbeatInfoKey;
4546

4647
//! EventInfo dictionary keys for events with type kMemfaultEventType_Trace.

components/include/memfault/default_config.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,26 @@ extern "C" {
296296
"memfault_metrics_heartbeat_config.def"
297297
#endif
298298

299+
//! Enable the sync_successful metric API
300+
#ifndef MEMFAULT_METRICS_SYNC_SUCCESS
301+
#define MEMFAULT_METRICS_SYNC_SUCCESS 0
302+
#endif
303+
304+
//! Enable the sync_memfault_successful metric API
305+
#ifndef MEMFAULT_METRICS_MEMFAULT_SYNC_SUCCESS
306+
#define MEMFAULT_METRICS_MEMFAULT_SYNC_SUCCESS 0
307+
#endif
308+
309+
//! Enable the connectivity_connected_time_ms metric API
310+
#ifndef MEMFAULT_METRICS_CONNECTIVITY_CONNECTED_TIME
311+
#define MEMFAULT_METRICS_CONNECTIVITY_CONNECTED_TIME 0
312+
#endif
313+
314+
//! Enable the battery metrics API
315+
#ifndef MEMFAULT_METRICS_BATTERY_ENABLE
316+
#define MEMFAULT_METRICS_BATTERY_ENABLE 0
317+
#endif
318+
299319
//
300320
// Panics Component Configs
301321
//

0 commit comments

Comments
 (0)