Skip to content

Commit 9d3ca21

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.9.2 (Build 8056)
1 parent 130dc3a commit 9d3ca21

File tree

23 files changed

+286
-18
lines changed

23 files changed

+286
-18
lines changed

CHANGELOG.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,59 @@ 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.9.2] - 2024-05-29
10+
11+
### :chart_with_upwards_trend: Improvements
12+
13+
- ESP-IDF:
14+
15+
- Fix CLI command, `memfault_ota_check`, to return 0 to the console component
16+
when an update is available.
17+
18+
- Add the temperature metric `cpu_temp` which is measured using an internal
19+
temperature sensor that many ESP32 boards have built-in. This metric is
20+
collected by default with the Kconfig `CONFIG_MEMFAULT_METRICS_CPU_TEMP=y`.
21+
22+
- Enable recording vprintf data into the Memfault log buffer through a vprintf
23+
hook. Users can call `memfault_esp_port_vprintf_log_hook()` from their
24+
vprintf handler so they can use both their vprintf handler and record logs
25+
into Memfault's log buffer. To use this feature, set
26+
`CONFIG_MEMFAULT_LOG_USE_VPRINTF_HOOK=n`.
27+
28+
- Fix a case where `esp_http_client_cleanup()` was not called in certain
29+
scenarios (for example, if the access point is connected, but there is no
30+
outside internet access), which resulted in a memory leak. Thanks to
31+
@mykmelez for providing the fix in
32+
[#71](https://github.com/memfault/memfault-firmware-sdk/pull/71) 🎉!
33+
34+
- Zephyr:
35+
36+
- Fix a bug in `memfault_zephyr_port_post_data_return_size()` where a positive
37+
value could be returned in the event of a failure instead of a negative
38+
value. This would result in `mflt post_chunks` returning a successful post
39+
message even though there was a failure such as a DNS lookup failure.
40+
41+
- Add the temperature metric `cpu_temp` which is measured using an internal
42+
temperature sensor that some Zephyr boards have. Similar to ESP-IDF, this
43+
metric is collected by default with the Kconfig
44+
`CONFIG_MEMFAULT_METRICS_CPU_TEMP=y`, but the board must have the device
45+
tree node `die-temp0` for this option to be used.
46+
47+
- Add an example for collecting thread stack usage metrics when the thread
48+
handles are not accessible in the desired scope. Users can leverage the
49+
Zephyr routine `k_thread_foreach()` to register a callback that will be
50+
called with each thread's `k_thread` handle. In the callback, users can read
51+
the stack usage via the handle and set their metrics.
52+
53+
### :boom: Breaking Changes
54+
55+
- Zephyr:
56+
57+
- Change the error return value for
58+
`memfault_zephyr_port_http_upload_sdk_data()` to a negative value instead
59+
of 1. This change aligns with the error return value for the other Zephyr
60+
HTTP client APIs, and simplifies logic in the HTTP client.
61+
962
## [1.9.1] - 2024-05-21
1063

1164
### :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: 7915
2-
GIT COMMIT: 435dc7c1d8
3-
VERSION: 1.9.1
1+
BUILD ID: 8056
2+
GIT COMMIT: 398b8ca5a7
3+
VERSION: 1.9.2

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 = 9, .patch = 1 }
23-
#define MEMFAULT_SDK_VERSION_STR "1.9.1"
22+
#define MEMFAULT_SDK_VERSION { .major = 1, .minor = 9, .patch = 2 }
23+
#define MEMFAULT_SDK_VERSION_STR "1.9.2"
2424

2525
#ifdef __cplusplus
2626
}

examples/esp32/apps/memfault_demo_app/main/main.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,44 @@ void esp_heap_trace_alloc_hook(void *ptr, size_t size, uint32_t caps) {
388388
}
389389
#endif
390390

391+
#if !defined(CONFIG_MEMFAULT_LOG_USE_VPRINTF_HOOK)
392+
// Demonstrate a custom vprintf hook that prefixes all log messages with
393+
// "[IDF]", before invoking the Memfault log hook, and then printing to stdout.
394+
static int prv_vprintf_hook(const char *fmt, va_list args) {
395+
char *fmt_annotated;
396+
int rv = asprintf(&fmt_annotated, "[IDF] %s", fmt);
397+
if ((rv < 0) || (fmt_annotated == NULL)) {
398+
return -1;
399+
}
400+
401+
#if defined(CONFIG_MEMFAULT)
402+
(void)memfault_esp_port_vprintf_log_hook(fmt_annotated, args);
403+
#endif
404+
405+
rv = vprintf(fmt_annotated, args);
406+
407+
free(fmt_annotated);
408+
409+
return rv;
410+
}
411+
412+
#endif
413+
391414
// This task started by cpu_start.c::start_cpu0_default().
392415
void app_main() {
393416
#if defined(CONFIG_MEMFAULT)
394417
#if !defined(CONFIG_MEMFAULT_AUTOMATIC_INIT)
395418
memfault_boot();
396419
#endif
420+
421+
#if !defined(CONFIG_MEMFAULT_LOG_USE_VPRINTF_HOOK)
422+
esp_log_set_vprintf(prv_vprintf_hook);
423+
ESP_LOGD("main", "debug log 🕵️");
424+
ESP_LOGI("main", "info log 🐢");
425+
ESP_LOGW("main", "warning log ⚠️");
426+
ESP_LOGE("main", "error log 🔥");
427+
#endif
428+
397429
memfault_device_info_dump();
398430

399431
g_unaligned_buffer = &s_my_buf[1];
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_ADC=y
2+
CONFIG_SENSOR=y
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/ {
2+
aliases {
3+
die-temp0 = &die_temp;
4+
};
5+
};
6+
7+
&die_temp {
8+
status = "okay";
9+
};
10+
11+
&adc1 {
12+
pinctrl-0 = <&adc1_in0_pa0>;
13+
pinctrl-names = "default";
14+
st,adc-prescaler = <4>;
15+
status = "okay";
16+
};

examples/zephyr/qemu/qemu-app/config/memfault_metrics_heartbeat_config.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ MEMFAULT_METRICS_KEY_DEFINE(MainStack_MinBytesFree, kMemfaultMetricType_Unsigned
22
// This example metric demonstrates a permille integer with a range of 0-1000 to be translated into
33
// a percentage 0.0-100.0%
44
MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE(main_thread_cpu_time_permille, kMemfaultMetricType_Unsigned, 10)
5+
MEMFAULT_METRICS_KEY_DEFINE(shell_uart_stack_free_bytes, kMemfaultMetricType_Unsigned)

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,35 @@ static int prv_run_example_memory_metrics(const struct shell *shell, size_t argc
211211
SHELL_CMD_REGISTER(memory_metrics, NULL, "Collects runtime memory metrics from application",
212212
prv_run_example_memory_metrics);
213213

214+
//! Callback to collect stack usage for specific threads
215+
static void prv_collect_thread_stack_usage_cb(const struct k_thread *thread, void *user_data) {
216+
// table mapping thread names to metric IDs
217+
static const struct {
218+
const char *name;
219+
MemfaultMetricId id;
220+
} threads[] = {
221+
{ "shell_uart", MEMFAULT_METRICS_KEY(shell_uart_stack_free_bytes) },
222+
};
223+
224+
// scan for a matching thread name
225+
for (size_t i = 0; i < ARRAY_SIZE(threads); i++) {
226+
if (strncmp(thread->name, threads[i].name, CONFIG_THREAD_MAX_NAME_LEN) == 0) {
227+
// get the stack usage and record in the matching metric id
228+
size_t stack_free_bytes;
229+
k_thread_stack_space_get(thread, &stack_free_bytes);
230+
memfault_metrics_heartbeat_set_unsigned(threads[i].id, stack_free_bytes);
231+
}
232+
}
233+
}
234+
214235
// Override function to collect the app metric MainStack_MinBytesFree
215236
// and print current metric values
216237
void memfault_metrics_heartbeat_collect_data(void) {
217238
prv_collect_main_thread_stack_free();
218239
prv_collect_main_thread_run_stats();
240+
241+
k_thread_foreach(prv_collect_thread_stack_usage_cb, NULL);
242+
219243
memfault_metrics_heartbeat_debug_print();
220244
}
221245

examples/zephyr/qemu/qemu-app/west.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ manifest:
1919
name-allowlist:
2020
- cmsis
2121
- picolibc
22+
- hal_stm32
2223

2324
- name: memfault-firmware-sdk
2425
path: modules/lib/memfault-firmware-sdk

examples/zephyr/stm32l4_disco/apps/memfault_demo_app/prj.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,7 @@ CONFIG_MEMFAULT_LOGGING_RAM_SIZE=512
8282

8383
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
8484
CONFIG_HEAP_MEM_POOL_SIZE=1024
85+
86+
# Currently not supported on older Zephyr, so explicitly disable until this
87+
# sample is updated
88+
CONFIG_MEMFAULT_METRICS_CPU_TEMP=n

0 commit comments

Comments
 (0)