Skip to content

Commit 130caec

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 0.31.5 (Build 481181)
1 parent 6f3f1c2 commit 130caec

File tree

11 files changed

+109
-44
lines changed

11 files changed

+109
-44
lines changed

CHANGES.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
### Changes between Memfault SDK 0.31.5 and SDK 0.31.4 - July 22, 2022
2+
3+
#### :chart_with_upwards_trend: Improvements
4+
5+
- Zephyr port: enable proper backtraces for Zephyr `__ASSERT()` macro on
6+
aarch32/cortex_m. Prior to this fix, crashes from `__ASSERT()` triggering
7+
would show an incorrect PC/LR for the active thread.
8+
9+
- Support for pre-release nRF Connect SDK v2.0.99 and Zephyr > v3.1:
10+
- Upcoming nRF Connect SDK and Zephyr releases removed logging v1. Add build
11+
support for these changes, and keep backwards compatibility for previous nRF
12+
Connect SDK/Zephyr releases
13+
- Correct an issue in the Memfault logging v2 backend, when the system was
14+
invoked from an ISR context. This could happen due to a recent change, in
15+
Memfault SDK v0.31.1, where the Zephyr fatal informational logs were output
16+
from `memfault_platform_reboot()` by default. It did not impact the
17+
collected backtrace, but it would show a nuisance `__ASSERT()` in the
18+
console output, if `CONFIG_ASSERT=y`.
19+
20+
#### :house: Internal
21+
22+
- Fix a compilation issue in the Dialog example app from the removal of
23+
`memfault_demo_cli_cmd_print_chunk()` in Memfault SDK release v0.31.4.
24+
125
### Changes between Memfault SDK 0.31.4 and SDK 0.31.3 - July 19, 2022
226

327
#### :chart_with_upwards_trend: Improvements

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
BUILD ID: 478452
2-
GIT COMMIT: 56592ceef
1+
BUILD ID: 481181
2+
GIT COMMIT: 95031d142

components/include/memfault/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef struct {
1919
uint8_t patch;
2020
} sMfltSdkVersion;
2121

22-
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 31, .patch = 4 }
22+
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 31, .patch = 5 }
2323

2424
#ifdef __cplusplus
2525
}

examples/dialog/da145xx/apps/memfault_demo_app/Eclipse/.project

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@
169169
<type>1</type>
170170
<locationURI>PARENT-6-PROJECT_LOC/components/demo/src/panics/memfault_demo_cli_aux.c</locationURI>
171171
</link>
172-
<link>
173-
<name>memfault_components/memfault_demo_cli_print_chunk.c</name>
174-
<type>1</type>
175-
<locationURI>PARENT-6-PROJECT_LOC/components/demo/src/memfault_demo_cli_print_chunk.c</locationURI>
176-
</link>
177172
<link>
178173
<name>memfault_components/memfault_demo_cli_trace_event.c</name>
179174
<type>1</type>

ports/zephyr/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,15 @@ config MEMFAULT_INIT_LEVEL_POST_KERNEL
290290
Set the Memfault initialization SYS_INIT priority level to
291291
"POST_KERNEL". Default is "APPLICATION".
292292

293+
config MEMFAULT_CATCH_ZEPHYR_ASSERT
294+
bool "Support backtrace through Zephyr __ASSERT() calls"
295+
default y
296+
help
297+
When enabled, Memfault will support proper backtraces when a Zephyr
298+
__ASSERT() trips. If disabled (i.e. user needs a custom implementation
299+
of assert_post_action()), backtraces will not be correctly captured
300+
from __ASSERT() macro call sites, unless assert_post_action() contains
301+
a MEMFAULT_ASSERT() invocation.
293302
rsource "ncs/Kconfig"
294303

295304
endif # MEMFAULT

ports/zephyr/common/memfault_demo_cli.c

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,11 @@
66
//! @brief
77
//! Adds a basic set of commands for interacting with Memfault SDK
88

9-
#include "memfault/demo/cli.h"
10-
119
#include <shell/shell.h>
1210

13-
#include "memfault/core/data_export.h"
14-
#include "memfault/core/debug_log.h"
15-
#include "memfault/core/platform/core.h"
16-
#include "memfault/core/reboot_tracking.h"
17-
#include "memfault/core/trace_event.h"
18-
#include "memfault/metrics/metrics.h"
11+
#include "memfault/components.h"
1912
#include "memfault/ports/zephyr/http.h"
13+
#include "zephyr_release_specific_headers.h"
2014

2115
static int prv_clear_core_cmd(const struct shell *shell, size_t argc, char **argv) {
2216
return memfault_demo_cli_cmd_clear_core(argc, argv);
@@ -30,6 +24,14 @@ static int prv_crash_example(const struct shell *shell, size_t argc, char **argv
3024
return memfault_demo_cli_cmd_crash(argc, argv);
3125
}
3226

27+
static int prv_zephyr_assert_example(const struct shell *shell, size_t argc, char **argv) {
28+
#if !CONFIG_ASSERT
29+
MEMFAULT_LOG_WARN("CONFIG_ASSERT was disabled in the build, this command will have no effect");
30+
#endif
31+
__ASSERT(0, "test assert");
32+
return 0;
33+
}
34+
3335
static int prv_test_log(const struct shell *shell, size_t argc, char **argv) {
3436
return memfault_demo_cli_cmd_test_log(argc, argv);
3537
}
@@ -48,7 +50,8 @@ static int prv_hang_example(const struct shell *shell, size_t argc, char **argv)
4850
#else
4951
MEMFAULT_LOG_DEBUG("Hanging system and waiting for watchdog!");
5052
#endif
51-
while (1) { }
53+
while (1) {
54+
}
5255
return -1;
5356
}
5457

@@ -102,7 +105,8 @@ static bool prv_handle_download_complete(void *user_ctx) {
102105
}
103106
#endif /* CONFIG_MEMFAULT_HTTP_ENABLE */
104107

105-
static int prv_check_and_fetch_ota_payload_cmd(const struct shell *shell, size_t argc, char **argv) {
108+
static int prv_check_and_fetch_ota_payload_cmd(const struct shell *shell, size_t argc,
109+
char **argv) {
106110
#if defined(CONFIG_MEMFAULT_HTTP_ENABLE)
107111
uint8_t working_buf[256];
108112

@@ -147,25 +151,30 @@ static int prv_trigger_heartbeat(const struct shell *shell, size_t argc, char **
147151
static int prv_test_reboot(const struct shell *shell, size_t argc, char **argv) {
148152
memfault_reboot_tracking_mark_reset_imminent(kMfltRebootReason_UserReset, NULL);
149153
memfault_platform_reboot();
150-
return 0; // should be unreachable
154+
return 0; // should be unreachable
151155
}
152156

153157
SHELL_STATIC_SUBCMD_SET_CREATE(
154-
sub_memfault_cmds,
155-
SHELL_CMD(reboot, NULL, "trigger a reboot and record it using memfault", prv_test_reboot),
156-
SHELL_CMD(get_core, NULL, "gets the core", prv_get_core_cmd),
157-
SHELL_CMD(clear_core, NULL, "clear the core", prv_clear_core_cmd),
158-
SHELL_CMD(crash, NULL, "trigger a crash", prv_crash_example),
159-
SHELL_CMD(test_log, NULL, "Writes test logs to log buffer", prv_test_log),
160-
SHELL_CMD(trigger_logs, NULL, "Trigger capture of current log buffer contents", prv_trigger_logs),
161-
SHELL_CMD(hang, NULL, "trigger a hang to test watchdog functionality", prv_hang_example),
162-
SHELL_CMD(export, NULL, "dump chunks collected by Memfault SDK using https://mflt.io/chunk-data-export", prv_chunk_data_export),
163-
SHELL_CMD(trace, NULL, "Capture an example trace event", prv_example_trace_event_capture),
164-
SHELL_CMD(get_device_info, NULL, "display device information", prv_get_device_info),
165-
SHELL_CMD(post_chunks, NULL, "Post Memfault data to cloud", prv_post_data),
166-
SHELL_CMD(trigger_heartbeat, NULL, "Trigger an immediate capture of all heartbeat metrics", prv_trigger_heartbeat),
167-
SHELL_CMD(get_latest_release, NULL, "checks to see if new ota payload is available", prv_check_and_fetch_ota_payload_cmd),
168-
SHELL_SUBCMD_SET_END /* Array terminated. */
158+
sub_memfault_cmds,
159+
SHELL_CMD(reboot, NULL, "trigger a reboot and record it using memfault", prv_test_reboot),
160+
SHELL_CMD(get_core, NULL, "gets the core", prv_get_core_cmd),
161+
SHELL_CMD(clear_core, NULL, "clear the core", prv_clear_core_cmd),
162+
SHELL_CMD(crash, NULL, "trigger a crash", prv_crash_example),
163+
SHELL_CMD(zephyr_assert, NULL, "trigger a zephyr __ASSERT", prv_zephyr_assert_example),
164+
SHELL_CMD(test_log, NULL, "Writes test logs to log buffer", prv_test_log),
165+
SHELL_CMD(trigger_logs, NULL, "Trigger capture of current log buffer contents", prv_trigger_logs),
166+
SHELL_CMD(hang, NULL, "trigger a hang to test watchdog functionality", prv_hang_example),
167+
SHELL_CMD(export, NULL,
168+
"dump chunks collected by Memfault SDK using https://mflt.io/chunk-data-export",
169+
prv_chunk_data_export),
170+
SHELL_CMD(trace, NULL, "Capture an example trace event", prv_example_trace_event_capture),
171+
SHELL_CMD(get_device_info, NULL, "display device information", prv_get_device_info),
172+
SHELL_CMD(post_chunks, NULL, "Post Memfault data to cloud", prv_post_data),
173+
SHELL_CMD(trigger_heartbeat, NULL, "Trigger an immediate capture of all heartbeat metrics",
174+
prv_trigger_heartbeat),
175+
SHELL_CMD(get_latest_release, NULL, "checks to see if new ota payload is available",
176+
prv_check_and_fetch_ota_payload_cmd),
177+
SHELL_SUBCMD_SET_END /* Array terminated. */
169178
);
170179

171180
SHELL_CMD_REGISTER(mflt, &sub_memfault_cmds, "Memfault Test Commands", NULL);

ports/zephyr/common/memfault_logging.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,16 @@ static void prv_log_process(const struct log_backend *const backend, union log_m
6666

6767
static void prv_log_dropped(const struct log_backend *const backend, uint32_t cnt);
6868
const struct log_backend_api log_backend_mflt_api = {
69-
#if MEMFAULT_ZEPHYR_VERSION_GT(2, 5)
69+
// The CONFIG_LOG2/1 options were removed after the 3.1 release series, so we no
70+
// longer can use them to assign the correct backend. Luckily there's only one
71+
// log type now, so it can just be set directly.
72+
#if MEMFAULT_ZEPHYR_VERSION_GT(3, 1)
73+
.process = prv_log_process,
74+
#elif MEMFAULT_ZEPHYR_VERSION_GT(2, 5)
7075
.process = IS_ENABLED(CONFIG_LOG2) ? prv_log_process : NULL,
7176
#endif
77+
78+
// Old-style logging backend API
7279
#if !MEMFAULT_ZEPHYR_VERSION_GT(3, 1)
7380
.put = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? NULL : prv_log_put,
7481
.put_sync_string = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? prv_log_put_sync_string : NULL,
@@ -86,6 +93,12 @@ LOG_BACKEND_DEFINE(log_backend_mflt, log_backend_mflt_api, true);
8693

8794
// Tie Memfault's log function to the Zephyr buffer sender. This is *the* connection to Memfault.
8895
static int prv_log_out(uint8_t *data, size_t length, void *ctx) {
96+
if (memfault_arch_is_inside_isr()) {
97+
// In synchronous mode, logging can occur from ISRs. The zephyr fault handlers are chatty so
98+
// don't save info while in an ISR to avoid wrapping over the info we are collecting.
99+
return (int) length;
100+
}
101+
89102
// Note: Context should always be populated. If it is not, flag the log as an _Error
90103
const eMemfaultPlatformLogLevel log_level = ctx != NULL ? *(eMemfaultPlatformLogLevel*)ctx :
91104
kMemfaultPlatformLogLevel_Error;

ports/zephyr/common/memfault_platform_core.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@
88
#include <init.h>
99
#include <soc.h>
1010

11-
#include "memfault/core/build_info.h"
12-
#include "memfault/core/compiler.h"
13-
#include "memfault/core/event_storage.h"
14-
#include "memfault/core/reboot_tracking.h"
15-
#include "memfault/core/trace_event.h"
16-
#include "memfault/panics/coredump.h"
11+
#include "memfault/components.h"
1712
#include "memfault/ports/reboot_reason.h"
18-
#include "memfault/ports/zephyr/version.h"
13+
#include "zephyr_release_specific_headers.h"
1914

2015
#if !MEMFAULT_ZEPHYR_VERSION_GT(2, 5)
2116

@@ -55,6 +50,23 @@ uint64_t memfault_platform_get_time_since_boot_ms(void) {
5550
return k_uptime_get();
5651
}
5752

53+
//! Provide a strong implementation of assert_post_action for Zephyr's built-in
54+
//! __ASSERT() macro.
55+
#if CONFIG_MEMFAULT_CATCH_ZEPHYR_ASSERT
56+
#ifdef CONFIG_ASSERT_NO_FILE_INFO
57+
void assert_post_action(void)
58+
#else
59+
void assert_post_action(const char *file, unsigned int line)
60+
#endif
61+
{
62+
#ifndef CONFIG_ASSERT_NO_FILE_INFO
63+
ARG_UNUSED(file);
64+
ARG_UNUSED(line);
65+
#endif
66+
MEMFAULT_ASSERT(0);
67+
}
68+
#endif
69+
5870
// On boot-up, log out any information collected as to why the
5971
// reset took place
6072

ports/zephyr/v1.14/zephyr_release_specific_headers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
extern "C" {
1313
#endif
1414

15-
#include <misc/reboot.h>
15+
#include <misc/__assert.h>
1616
#include <misc/printk.h>
17+
#include <misc/reboot.h>
1718

1819
#ifdef __cplusplus
1920
}

ports/zephyr/v2.0/zephyr_release_specific_headers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
extern "C" {
1313
#endif
1414

15-
#include <power/reboot.h>
1615
#include <misc/printk.h>
16+
#include <power/reboot.h>
17+
#include <sys/__assert.h>
1718

1819
#ifdef __cplusplus
1920
}

0 commit comments

Comments
 (0)