Skip to content

Commit d7ca406

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.7.1 (Build 6524)
1 parent 5a16c1d commit d7ca406

File tree

62 files changed

+1325
-148
lines changed

Some content is hidden

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

62 files changed

+1325
-148
lines changed

CHANGELOG.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,58 @@
11
# Memfault Firmware SDK Changelog
22

3-
## [1.7.0] - 2024-01-29
3+
## [1.7.1] - 2024-02-28
4+
5+
### :chart_with_upwards_trend: Improvements
6+
7+
- General:
8+
9+
- Fix a reboot reason test on MacOS by adding a stub implementation of a
10+
function to avoid an empty archive not allowed by the system clang install
11+
- Add a new macro `MEMFAULT_REBOOT_MARK_RESET_IMMINENT_CUSTOM()` that is more
12+
concise for custom reboot reasons by taking the reboot reason name directly.
13+
Previously, `MEMFAULT_REBOOT_MARK_RESET_IMMINENT()` was the only option,
14+
which requires passing a key with `MEMFAULT_REBOOT_REASON_KEY()`.
15+
- Add a session start callback with
16+
`memfault_metrics_session_register_start_cb()`. This change enables, for
17+
example, tracking battery percent drop across sessions; battery state
18+
tracking variables can now be initialized at the start of a session.
19+
- Add a coredump storage test to the self test which will now test the
20+
coredump storage implementations and check available storage capacity. This
21+
is currently experimental and must be explicitly enabled with the Kconfig
22+
`CONFIG_MEMFAULT_SHELL_SELF_TEST_COREDUMP_STORAGE=y` on Zephyr,
23+
`CONFIG_MEMFAULT_CLI_SELF_TEST_COREDUMP_STORAGE=y` on ESP-IDF, or by adding
24+
`#define MEMFAULT_DEMO_CLI_SELF_TEST_COREDUMP_STORAGE 1` to your
25+
`memfault_platform_config.h` for other platforms.
26+
- Convert the previous `heartbeat_dump` command to `metrics_dump` that can
27+
either dump all current heartbeat metrics with `metrics_dump heartbeat` or
28+
all session metrics with `metrics_dump sessions` that haven't yet been
29+
exported. These commands help with testing metrics collection locally
30+
without needing to push chunks to Memfault.
31+
- Apply a handful of changes to fix items raised by a new static analyzer
32+
- Fix a minor formatting issue that was causing a compilation error for CC ARM
33+
- Update support links to refer to the preferred site
34+
https://mflt.io/contact-support instead of the Memfault support email. This
35+
link will redirect to a form where questions can be sent to the Memfault
36+
support team.
37+
- Update the `README.md`s in example apps to point to the
38+
[Demo CLI](https://docs.memfault.com/docs/mcu/demo-cli) page on the Memfault
39+
docs website where comprehensive information is available on commands and
40+
their output
41+
42+
- nRF-Connect SDK:
43+
44+
- Fix a problem caused by mismatched root certificates in modem storage. This
45+
change will ensure that all certificates are updated if they do not match
46+
expected contents. Prior to v1.7.1, the SDK would only update a certificate
47+
by checking each tag for certificate existence, not certificate content. In
48+
v1.3.0, the order of root certificates was changed and one was removed. On
49+
devices running pre-1.3.0 firmware, updating to later versions can hit a
50+
mismatch between the expected certificates and those in modem storage.
51+
- Remove a root certificate deprecated in v1.3.0 if present in modem storage.
52+
Devices using an SDK version before v1.3.0 may contain a now deprecated root
53+
certificate.
54+
55+
## [1.7.0] - 2024-02-15
456

557
### :rocket: New Features
658

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ the top for build & test coverage status of the `master` branch.
161161
- I'm getting error XYZ, what to do now?
162162
163163
- Don't hesitate to contact us for help! You can reach us through
164-
164+
<https://mflt.io/contact-support>.
165165
166166
# License
167167

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
BUILD ID: 6257
2-
GIT COMMIT: 8cd2342158
3-
VERSION: 1.7.0
1+
BUILD ID: 6524
2+
GIT COMMIT: 14c45caf49
3+
VERSION: 1.7.1

components/core/src/memfault_event_storage.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ static bool prv_save_event_to_persistent_storage(void) {
329329
return false;
330330
}
331331

332+
MEMFAULT_SDK_ASSERT(g_memfault_platform_nv_event_storage_impl.write != NULL);
333+
332334
const bool success =
333335
g_memfault_platform_nv_event_storage_impl.write(prv_event_storage_read_ram, total_size);
334336
if (success) {

components/core/src/memfault_heap_stats.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ bool memfault_heap_stats_empty(void) {
6868
static uint16_t prv_get_previous_entry(uint16_t search_entry_index) {
6969
uint16_t index = MEMFAULT_HEAP_STATS_LIST_END;
7070

71-
for (uint16_t i = 0; i < MEMFAULT_ARRAY_SIZE(g_memfault_heap_stats_pool); i++) {
71+
for (size_t i = 0; i < MEMFAULT_ARRAY_SIZE(g_memfault_heap_stats_pool); i++) {
7272
sMfltHeapStatEntry *entry = &g_memfault_heap_stats_pool[i];
7373
if (entry->info.in_use && entry->info.next_entry_index == search_entry_index) {
74-
index = i;
74+
index = (uint16_t)i;
7575
break;
7676
}
7777
}
@@ -87,16 +87,16 @@ static uint16_t prv_get_new_entry_index(void) {
8787
sMfltHeapStatEntry *entry;
8888
uint16_t unused_index = MEMFAULT_HEAP_STATS_LIST_END;
8989

90-
for (uint16_t i = 0; i < MEMFAULT_ARRAY_SIZE(g_memfault_heap_stats_pool); i++) {
90+
for (size_t i = 0; i < MEMFAULT_ARRAY_SIZE(g_memfault_heap_stats_pool); i++) {
9191
entry = &g_memfault_heap_stats_pool[i];
9292

9393
if (!entry->info.in_use) {
9494
if (entry->info.size == 0) {
95-
return i; // favor never used entries
95+
return (uint16_t)i; // favor never used entries
9696
}
9797
// save the first inactive entry found
9898
if (unused_index == MEMFAULT_HEAP_STATS_LIST_END) {
99-
unused_index = i;
99+
unused_index = (uint16_t)i;
100100
}
101101
}
102102
}
@@ -152,13 +152,13 @@ void memfault_heap_stats_free(const void *ptr) {
152152
g_memfault_heap_stats.in_use_block_count--;
153153

154154
// if the pointer exists in the tracked stats, mark it as freed
155-
for (uint16_t i = 0; i < MEMFAULT_ARRAY_SIZE(g_memfault_heap_stats_pool); i++) {
155+
for (size_t i = 0; i < MEMFAULT_ARRAY_SIZE(g_memfault_heap_stats_pool); i++) {
156156
sMfltHeapStatEntry *entry = &g_memfault_heap_stats_pool[i];
157157
if ((entry->ptr == ptr) && entry->info.in_use) {
158158
entry->info.in_use = 0;
159159

160160
// Find the entry previous to the removed entry
161-
uint16_t previous_entry_index = prv_get_previous_entry(i);
161+
uint16_t previous_entry_index = prv_get_previous_entry((uint16_t)i);
162162

163163
// If list head removed, set next entry as new list head
164164
if (g_memfault_heap_stats.stats_pool_head == i) {

components/core/src/memfault_self_test.c

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
#include "memfault/panics/coredump_impl.h"
2727
#include "memfault_self_test_private.h"
2828

29+
// Wrap this definition to prevent unused macro warning
30+
#if !MEMFAULT_DEMO_CLI_SELF_TEST_COREDUMP_STORAGE
31+
#ifndef MEMFAULT_SELF_TEST_COREDUMP_STORAGE_DISABLE_MSG
32+
#define MEMFAULT_SELF_TEST_COREDUMP_STORAGE_DISABLE_MSG \
33+
"Set MEMFAULT_DEMO_CLI_SELF_TEST_COREDUMP_STORAGE in memfault_platform_config.h"
34+
#endif // !MEMFAULT_SELF_TEST_COREDUMP_STORAGE_DISABLE_MSG
35+
#endif // !MEMFAULT_DEMO_CLI_SELF_TEST_COREDUMP_STORAGE
36+
2937
#if !defined(MEMFAULT_UNITTEST_SELF_TEST)
3038

3139
typedef enum {
@@ -140,9 +148,9 @@ static void prv_device_info_test_describe(uint32_t results) {
140148
}
141149

142150
MEMFAULT_LOG_ERROR("One or more fields is invalid. Check for correct length and contents");
143-
for (uint8_t i = 0; i < kDeviceInfoField_Max; i++) {
151+
for (size_t i = 0; i < kDeviceInfoField_Max; i++) {
144152
// Check if bit cleared, cleared bits indicate an invalid field
145-
if ((results & (1 << i))) {
153+
if ((results & (1u << i))) {
146154
MEMFAULT_LOG_ERROR("%s invalid", s_device_info_field_names[i]);
147155
}
148156
}
@@ -232,7 +240,7 @@ static void prv_print_region_group_info(const char *group_name, const sMfltCored
232240
MEMFAULT_LOG_INFO("-----------------------------");
233241
MEMFAULT_LOG_INFO("%10s|%10s|%6s|", "Address", "Length", "Type");
234242
MEMFAULT_LOG_INFO("-----------------------------");
235-
for (size_t i = 0; i < num_regions; i++) {
243+
for (size_t i = 0; (regions != NULL) && (i < num_regions); i++) {
236244
sMfltCoredumpRegion region = regions[i];
237245
MEMFAULT_LOG_INFO("0x%08" PRIxPTR "|%10" PRIu32 "|%6u|", (uintptr_t)region.region_start,
238246
region.region_size, region.type);
@@ -378,6 +386,42 @@ uint32_t memfault_self_test_time_test(void) {
378386
return result;
379387
}
380388

389+
uint32_t memfault_self_test_coredump_storage_capacity_test(void) {
390+
MEMFAULT_SELF_TEST_PRINT_HEADER("Coredump Storage Capacity Test");
391+
bool result = memfault_coredump_storage_check_size();
392+
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
393+
return result ? 0 : 1;
394+
}
395+
396+
uint32_t memfault_self_test_coredump_storage_test(void) {
397+
MEMFAULT_SELF_TEST_PRINT_HEADER("Coredump Storage Test");
398+
399+
if (memfault_coredump_has_valid_coredump(NULL)) {
400+
MEMFAULT_LOG_ERROR("Aborting test, valid coredump present");
401+
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
402+
return (1 << 0);
403+
}
404+
405+
// Wrap test with calls to disable/enable irqs to allow test to run uninterrupted
406+
// Abort if we cannot disable irqs
407+
bool irqs_disabled = memfault_self_test_platform_disable_irqs();
408+
if (!irqs_disabled) {
409+
MEMFAULT_LOG_ERROR("Aborting test, could not disable interrupts");
410+
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
411+
return (1 << 1);
412+
}
413+
414+
memfault_coredump_storage_debug_test_begin();
415+
if (!memfault_self_test_platform_enable_irqs()) {
416+
MEMFAULT_LOG_WARN("Failed to enable interrupts after test completed");
417+
}
418+
419+
bool result = memfault_coredump_storage_debug_test_finish();
420+
421+
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
422+
return result ? 0 : (1 << 2);
423+
}
424+
381425
#endif // defined(MEMFAULT_UNITTEST_SELF_TEST)
382426

383427
int memfault_self_test_run(uint32_t run_flags) {
@@ -403,5 +447,17 @@ int memfault_self_test_run(uint32_t run_flags) {
403447
if (run_flags & kMemfaultSelfTestFlag_PlatformTime) {
404448
result |= memfault_self_test_time_test();
405449
}
450+
if (run_flags & kMemfaultSelfTestFlag_CoredumpStorage) {
451+
#if MEMFAULT_DEMO_CLI_SELF_TEST_COREDUMP_STORAGE
452+
result |= memfault_self_test_coredump_storage_test();
453+
#else
454+
MEMFAULT_LOG_ERROR("Coredump storage test not enabled");
455+
MEMFAULT_LOG_ERROR(MEMFAULT_SELF_TEST_COREDUMP_STORAGE_DISABLE_MSG);
456+
result = 1;
457+
#endif
458+
}
459+
if (run_flags & kMemfaultSelfTestFlag_CoredumpStorageCapacity) {
460+
result |= memfault_self_test_coredump_storage_capacity_test();
461+
}
406462
return (result == 0) ? 0 : 1;
407463
}

components/core/src/memfault_self_test_private.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ uint32_t memfault_self_test_reboot_reason_test_verify(void);
6060
//! Runs tests against platform time functions
6161
uint32_t memfault_self_test_time_test(void);
6262

63+
//! Runs tests against platform coredump storage implementation
64+
//!
65+
//! This test will check for the existence of a valid coredump before proceeding and abort if one is
66+
//! found to prevent overwriting valid data
67+
uint32_t memfault_self_test_coredump_storage_test(void);
68+
69+
//! Runs test to check capacity of coredump storage against worst case
70+
uint32_t memfault_self_test_coredump_storage_capacity_test(void);
71+
6372
//! Internal implementation of strnlen
6473
//!
6574
//! Support for strnlen is inconsistent across a lot of libc implementations so we implement this

components/core/src/memfault_self_test_utils.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ static const struct {
3737
.name = "reboot_verify",
3838
.value = kMemfaultSelfTestFlag_RebootReasonVerify,
3939
},
40+
{
41+
.name = "coredump_storage",
42+
.value = kMemfaultSelfTestFlag_CoredumpStorage,
43+
},
4044
};
4145

4246
#define SELF_TEST_MAX_NAME_LEN 30
@@ -70,3 +74,13 @@ size_t memfault_strnlen(const char *str, size_t n) {
7074
MEMFAULT_WEAK void memfault_self_test_platform_delay(MEMFAULT_UNUSED uint32_t delay_ms) {
7175
MEMFAULT_LOG_ERROR("%s not implemented for this platform", __func__);
7276
}
77+
78+
MEMFAULT_WEAK bool memfault_self_test_platform_disable_irqs(void) {
79+
MEMFAULT_LOG_ERROR("%s not implemented for this platform", __func__);
80+
return false;
81+
}
82+
83+
MEMFAULT_WEAK bool memfault_self_test_platform_enable_irqs(void) {
84+
MEMFAULT_LOG_ERROR("%s not implemented for this platform", __func__);
85+
return false;
86+
}

components/demo/src/memfault_demo_shell_commands.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//! Command definitions for the minimal shell/console implementation.
88

99
#include <stddef.h>
10+
#include <string.h>
1011

1112
#include "memfault/core/compiler.h"
1213
#include "memfault/core/data_export.h"
@@ -52,8 +53,25 @@ MEMFAULT_WEAK void memfault_metrics_heartbeat_debug_trigger(void) {
5253
MEMFAULT_LOG_RAW("Disabled. metrics component integration required");
5354
}
5455

55-
int memfault_demo_cli_cmd_heartbeat_dump(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char *argv[]) {
56-
memfault_metrics_heartbeat_debug_print();
56+
MEMFAULT_WEAK void memfault_metrics_all_sessions_debug_print(void) {
57+
MEMFAULT_LOG_RAW("Disabled. metrics component integration required");
58+
}
59+
60+
static int memfault_demo_cli_cmd_metrics_dump(int argc, char *argv[]) {
61+
if (argc < 2) {
62+
MEMFAULT_LOG_RAW("Enter 'heartbeat' or 'sessions'");
63+
return 0;
64+
}
65+
66+
if (!strncmp(argv[1], "sessions", sizeof("sessions"))) {
67+
memfault_metrics_all_sessions_debug_print();
68+
} else if (!strncmp(argv[1], "heartbeat", sizeof("heartbeat"))) {
69+
memfault_metrics_heartbeat_debug_print();
70+
} else {
71+
MEMFAULT_LOG_RAW("Unknown option. Enter 'heartbeat' or 'sessions'");
72+
return 0;
73+
}
74+
5775
return 0;
5876
}
5977

@@ -83,9 +101,8 @@ static const sMemfaultShellCommand s_memfault_shell_commands[] = {
83101
{ "get_core", memfault_demo_cli_cmd_get_core, "Get coredump info" },
84102
{ "get_device_info", memfault_demo_cli_cmd_get_device_info, "Get device info" },
85103
{ "coredump_size", memfault_demo_cli_cmd_coredump_size, "Print the coredump storage capacity" },
86-
{ "heartbeat_dump", memfault_demo_cli_cmd_heartbeat_dump,
87-
"Dump current Memfault metrics heartbeat state" },
88-
{ "heartbeat", memfault_demo_cli_cmd_heartbeat, "Trigger a heartbeat" },
104+
{ "metrics_dump", memfault_demo_cli_cmd_metrics_dump,
105+
"Dump current heartbeat or session metrics" },
89106
//
90107
// Test commands for validating SDK functionality: https://mflt.io/mcu-test-commands
91108
//

components/include/memfault/core/reboot_tracking.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ void memfault_reboot_tracking_mark_reset_imminent(eMemfaultRebootReason reboot_r
125125
memfault_reboot_tracking_mark_reset_imminent(reason_, &mflt_reg_info); \
126126
} while (0)
127127

128+
//! Helper macro that behaves the same as `MEMFAULT_REBOOT_MARK_RESET_IMMINENT` but allows
129+
//! for a custom reboot reason to be specified without needed to use the
130+
//! `MEMFAULT_REBOOT_REASON_KEY` macro
131+
#define MEMFAULT_REBOOT_MARK_RESET_IMMINENT_CUSTOM(reason_) \
132+
MEMFAULT_REBOOT_MARK_RESET_IMMINENT(MEMFAULT_REBOOT_REASON_KEY(reason_))
133+
128134
//! Collects recent reset info and pushes it to memfault_event_storage so that the data can
129135
//! can be sent out using the Memfault data packetizer
130136
//!

0 commit comments

Comments
 (0)