Skip to content

Commit 0174f3e

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.7.7 (Build 7396)
1 parent 18b228b commit 0174f3e

26 files changed

+283
-37
lines changed

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,42 @@ 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.7.7] - 2024-04-15
10+
11+
- FreeRTOS:
12+
13+
- Add a compile time error when the
14+
[`ports/freertos/config/memfault_metrics_heartbeat_freertos_config.def`](memfault_metrics_heartbeat_freertos_config.def)
15+
file is not included from the user `memfault_metrics_heartbeat_config.def`
16+
file. Compilation would fail previously with hard-to-follow errors due to
17+
missing metrics definitions. This change makes the compilation error
18+
explicit.
19+
20+
- ESP-IDF:
21+
22+
- Permit disabling the Memfault logging hook into `esp_log_set_vprintf()` (by
23+
default this is enabled on system boot). Use
24+
`CONFIG_MEMFAULT_LOG_USE_VPRINTF_HOOK=n` to disable the Memfault hook. Note
25+
that this will disable capturing ESP-IDF logs in Memfault.
26+
27+
- Allow disabling the built-in Connectivity
28+
[Core Metric](https://mflt.io/core-metrics?platform=MCU) collection, which
29+
is enabled by default to track WiFi uptime. Use
30+
`CONFIG_MEMFAULT_ESP_WIFI_CONNECTIVITY_TIME_METRICS=n` to disable the
31+
built-in implementation.
32+
33+
- General:
34+
35+
- EXPERIMENTAL: Add the option to set a scale factor when defining a Metric.
36+
The scale factor will in the future be used to divide the uploaded metric
37+
values. For example, if a Metric is defined with a scale factor of `10`, all
38+
values reported for that Metric will be divided by `10` when received by
39+
Memfault. The resulting value is stored as a floating point number in
40+
Memfault.
41+
42+
- Minor tweak to the [Eclipse patcher script](scripts/eclipse_patch.py) to
43+
better handler folders with partially common path prefixes.
44+
945
## [1.7.6] - 2024-04-03
1046

1147
### :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: 7230
2-
GIT COMMIT: 28ff066c7d
3-
VERSION: 1.7.6
1+
BUILD ID: 7396
2+
GIT COMMIT: 4b94654821
3+
VERSION: 1.7.7

components/core/src/memfault_log_data_source.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,16 @@ typedef struct {
9292
};
9393
} sMfltLogEncodingCtx;
9494

95-
static bool prv_copy_msg_callback(sMfltLogIterator *iter, MEMFAULT_UNUSED size_t offset,
96-
const char *buf, size_t buf_len) {
95+
#if defined(MEMFAULT_UNITTEST)
96+
#if defined(__clang__)
97+
__attribute__((no_sanitize("undefined")))
98+
#else
99+
__attribute__((no_sanitize_undefined))
100+
#endif
101+
#endif
102+
static bool
103+
prv_copy_msg_callback(sMfltLogIterator *iter, MEMFAULT_UNUSED size_t offset, const char *buf,
104+
size_t buf_len) {
97105
sMfltLogEncodingCtx *const ctx = (sMfltLogEncodingCtx *)iter->user_ctx;
98106
return memfault_cbor_join(&ctx->encoder, buf, buf_len);
99107
}

components/demo/src/memfault_demo_shell.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
// the extension commands. This construct, despite being pretty intricate,
2525
// saves about ~28 bytes of code space over running the iteration twice in a
2626
// row, and keeps the iterator in one macro, instead of two.
27-
#define MEMFAULT_SHELL_FOR_EACH_COMMAND(command) \
28-
const sMemfaultShellCommand *command = g_memfault_shell_commands; \
29-
for (size_t i = 0; i < g_memfault_num_shell_commands + s_mflt_shell.num_extension_commands; \
30-
++i, command = (i < g_memfault_num_shell_commands) ? \
31-
&g_memfault_shell_commands[i] : \
32-
&s_mflt_shell.extension_commands[i - g_memfault_num_shell_commands])
27+
#define MEMFAULT_SHELL_FOR_EACH_COMMAND(command) \
28+
const sMemfaultShellCommand *command = g_memfault_shell_commands; \
29+
for (size_t i = 0; i < g_memfault_num_shell_commands + s_mflt_shell.num_extension_commands; \
30+
++i, command = (i < g_memfault_num_shell_commands) ? \
31+
&g_memfault_shell_commands[i] : \
32+
(s_mflt_shell.extension_commands ? \
33+
&s_mflt_shell.extension_commands[i - g_memfault_num_shell_commands] : \
34+
NULL))
3335
#else
3436
#define MEMFAULT_SHELL_FOR_EACH_COMMAND(command) \
3537
for (const sMemfaultShellCommand *command = g_memfault_shell_commands; \

components/include/memfault/default_config.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,13 @@ extern "C" {
335335
#define MEMFAULT_METRICS_BATTERY_ENABLE 0
336336
#endif
337337

338+
//! Set a scale factor to be used with battery_soc_pct and battery_soc_pct_drop. On ingestion,
339+
//! Memfault will scale down the received integer value of these metrics by
340+
//! MEMFAULT_METRICS_BATTERY_SOC_PCT_SCALE_VALUE. The default value is 1 (i.e. no change)
341+
#ifndef MEMFAULT_METRICS_BATTERY_SOC_PCT_SCALE_VALUE
342+
#define MEMFAULT_METRICS_BATTERY_SOC_PCT_SCALE_VALUE 1
343+
#endif
344+
338345
//
339346
// Panics Component Configs
340347
//

components/include/memfault/metrics/heartbeat_config.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ MEMFAULT_METRICS_KEY_DEFINE(operational_hours, kMemfaultMetricType_Unsigned)
3030
MEMFAULT_METRICS_KEY_DEFINE(operational_crashfree_hours, kMemfaultMetricType_Unsigned)
3131

3232
#if MEMFAULT_METRICS_BATTERY_ENABLE
33-
// State of Charge drop since the last heartbeat was collected, in percent
34-
MEMFAULT_METRICS_KEY_DEFINE(battery_soc_pct_drop, kMemfaultMetricType_Unsigned)
33+
// State of Charge drop since the last heartbeat was collected, use scale factor for non 0-100% representations
34+
MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE(battery_soc_pct_drop, kMemfaultMetricType_Unsigned, MEMFAULT_METRICS_BATTERY_SOC_PCT_SCALE_VALUE)
3535
MEMFAULT_METRICS_KEY_DEFINE(battery_discharge_duration_ms, kMemfaultMetricType_Unsigned)
3636
// Intentionally leave the range unset for this metric. Some platforms will
37-
// require a 0-100% range, some will require 0-1000 (0-100.0%), etc.
38-
MEMFAULT_METRICS_KEY_DEFINE(battery_soc_pct, kMemfaultMetricType_Unsigned)
37+
// require a 0-100% range, some will require 0-1000 (0-100.0%), etc. Use scale factor for non 0-100% representations
38+
MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE(battery_soc_pct, kMemfaultMetricType_Unsigned, MEMFAULT_METRICS_BATTERY_SOC_PCT_SCALE_VALUE)
3939
#endif

components/include/memfault/metrics/ids_impl.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ extern "C" {
3939
max_value, session_name) \
4040
MEMFAULT_METRICS_KEY_DEFINE(key_name, value_type)
4141

42+
#define MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE(key_name, value_type, scale_value) \
43+
MEMFAULT_METRICS_KEY_DEFINE(key_name, value_type)
44+
45+
#define MEMFAULT_METRICS_KEY_DEFINE_WITH_SESSION_AND_SCALE_VALUE(key_name, value_type, \
46+
session_key, scale_value) \
47+
MEMFAULT_METRICS_KEY_DEFINE(key_name, value_type)
48+
4249
#define MEMFAULT_METRICS_KEY_DEFINE(key_name, value_type) MEMFAULT_METRICS_KEY_DEFINE_(key_name)
4350
#include "memfault/metrics/heartbeat_config.def"
4451
#include MEMFAULT_METRICS_USER_HEARTBEAT_DEFS_FILE
@@ -50,6 +57,8 @@ extern "C" {
5057
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_SESSION
5158
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_RANGE_AND_SESSION
5259
#undef MEMFAULT_METRICS_KEY_DEFINE_
60+
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE
61+
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_SESSION_AND_SCALE_VALUE
5362

5463
#define MEMFAULT_METRICS_KEY_DEFINE_(key_name) kMfltMetricsIndex_##key_name,
5564

@@ -73,6 +82,13 @@ extern "C" {
7382
max_value, session_name) \
7483
MEMFAULT_METRICS_KEY_DEFINE(key_name, value_type)
7584

85+
#define MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE(key_name, value_type, scale_value) \
86+
MEMFAULT_METRICS_KEY_DEFINE(key_name, value_type)
87+
88+
#define MEMFAULT_METRICS_KEY_DEFINE_WITH_SESSION_AND_SCALE_VALUE(key_name, value_type, \
89+
session_key, scale_value) \
90+
MEMFAULT_METRICS_KEY_DEFINE(key_name, value_type)
91+
7692
#define MEMFAULT_METRICS_KEY_DEFINE(key_name, value_type) MEMFAULT_METRICS_KEY_DEFINE_(key_name)
7793

7894
typedef enum MfltMetricsIndex {
@@ -85,6 +101,8 @@ typedef enum MfltMetricsIndex {
85101
#undef MEMFAULT_METRICS_SESSION_KEY_DEFINE
86102
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_SESSION
87103
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_RANGE_AND_SESSION
104+
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE
105+
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_SESSION_AND_SCALE_VALUE
88106
} eMfltMetricsIndex;
89107

90108
#define MEMFAULT_METRICS_SESSION_KEY_DEFINE(key_name) kMfltMetricsSessionKey_##key_name,
@@ -95,6 +113,10 @@ typedef enum MfltMetricsIndex {
95113
#define MEMFAULT_METRICS_KEY_DEFINE_WITH_SESSION(key_name, value_type, session_name)
96114
#define MEMFAULT_METRICS_KEY_DEFINE_WITH_RANGE_AND_SESSION(key_name, value_type, min_value, \
97115
max_value, session_name)
116+
#define MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE(key_name, value_type, scale_value)
117+
118+
#define MEMFAULT_METRICS_KEY_DEFINE_WITH_SESSION_AND_SCALE_VALUE(key_name, value_type, \
119+
session_key, scale_value)
98120

99121
typedef enum MfltMetricSessionIndex {
100122
#include "memfault/metrics/heartbeat_config.def"
@@ -107,6 +129,8 @@ typedef enum MfltMetricSessionIndex {
107129
#undef MEMFAULT_METRICS_STRING_KEY_DEFINE_WITH_SESSION
108130
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_SESSION
109131
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_RANGE_AND_SESSION
132+
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE
133+
#undef MEMFAULT_METRICS_KEY_DEFINE_WITH_SESSION_AND_SCALE_VALUE
110134
} eMfltMetricsSessionIndex;
111135

112136
//! Stub define to detect accidental usage outside of the heartbeat config files

components/include/memfault/metrics/metrics.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ typedef enum MemfaultMetricValueType {
107107
max_value, session_key) \
108108
MEMFAULT_METRICS_KEY_DEFINE_TRAP_()
109109

110+
//! Same as 'MEMFAULT_METRICS_KEY_DEFINE`, with scale value specified
111+
//!
112+
//! A scale value is used to scale down integer metric types. When a scale value is defined for a
113+
//! metric key, On ingestion, Memfault will apply this transformation to the metric value:
114+
//! transformed_metric_value = metric_value / scale_value
115+
//! Use this value to scale integer values down, like converting a permyriad value into percent
116+
#define MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE(key_name, value_type, scale_value) \
117+
MEMFAULT_METRICS_KEY_DEFINE_TRAP_()
118+
119+
//! Same as 'MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE', with session specified
120+
#define MEMFAULT_METRIS_KEY_DEFINE_WITH_SESSION_AND_SCALE_VALUE(key_name, value_type, session_key, \
121+
scale_value) \
122+
MEMFAULT_METRICS_KEY_DEFINE_TRAP_()
123+
110124
//! Define a metric session.
111125
//!
112126
//! A metric session is analogous to a heartbeat, but you can use it to track metrics

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 = 7, .patch = 6 }
23-
#define MEMFAULT_SDK_VERSION_STR "1.7.6"
22+
#define MEMFAULT_SDK_VERSION { .major = 1, .minor = 7, .patch = 7 }
23+
#define MEMFAULT_SDK_VERSION_STR "1.7.7"
2424

2525
#ifdef __cplusplus
2626
}

0 commit comments

Comments
 (0)