Skip to content

Commit b94e256

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 0.43.0 (Build 1963)
1 parent 920a1ee commit b94e256

Some content is hidden

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

52 files changed

+1842
-71
lines changed

CHANGES.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
### Changes between Memfault SDK 0.43.0 and 0.42.1 - April 18, 2023
2+
3+
#### :rocket: New Features
4+
5+
- Add coredump support for Cortex-R chips (ARMv7-R)
6+
7+
#### :chart_with_upwards_trend: Improvements
8+
9+
- Add a QEMU-based FreeRTOS example project, find it under
10+
[examples/freertos](examples/freertos)
11+
- Switch `printf` function attribute to use `__printf__`, to avoid collision
12+
with user code that redefines the `printf` token
13+
14+
- Zephyr:
15+
16+
- Compute thread stack high watermark values on-target when capturing a
17+
coredump. This enables showing high watermark information in the Memfault
18+
coredump analysis view without capturing the full stack for a thread
19+
120
### Changes between Memfault SDK 0.42.1 and 0.42.0 - April 4, 2023
221

322
#### :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: 1866
2-
GIT COMMIT: 96e2f7fa4
1+
BUILD ID: 1963
2+
GIT COMMIT: bcb826788

components/core/src/arch_arm_cortex_m.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "memfault/core/compiler.h"
1010
#include "memfault/core/platform/core.h"
1111

12-
#if MEMFAULT_COMPILER_ARM
12+
#if MEMFAULT_COMPILER_ARM_CORTEX_M
1313

1414
bool memfault_arch_is_inside_isr(void) {
1515
// We query the "Interrupt Control State Register" to determine
@@ -43,4 +43,4 @@ void memfault_platform_halt_if_debugging(void) {
4343
MEMFAULT_BREAKPOINT(77);
4444
}
4545

46-
#endif /* MEMFAULT_COMPILER_ARM */
46+
#endif /* MEMFAULT_COMPILER_ARM_CORTEX_M */

components/core/src/memfault_log.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,19 @@ void memfault_log_export_log(sMemfaultLog *log) {
306306

307307
void memfault_log_export_logs(void) {
308308
while (1) {
309+
// the TI ARM compiler warns about enumerated type mismatch in this
310+
// zero-initializer, but we depend on the C99 spec (vs. the gcc extension,
311+
// empty brace {}), so suppress the diagnostic here. Clang throws an invalid
312+
// -Wmissing-field-initializers warning if we just cast, unfortunately.
313+
#if defined(__TI_ARM__)
314+
#pragma diag_push
315+
#pragma diag_remark 190
316+
#endif
309317
sMemfaultLog log = {0};
318+
#if defined(__TI_ARM__)
319+
#pragma diag_pop
320+
#endif
321+
310322
const bool log_found = memfault_log_read(&log);
311323
if (!log_found) {
312324
break;

components/core/src/memfault_ram_reboot_info_tracking.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ static bool prv_read_reset_info(sMfltResetReasonInfo *info) {
115115
//! @param reboot_reg_reason New reboot reason from this boot
116116
//! @param prior_stored_reason Prior reboot reason stored in s_mflt_reboot_info
117117
static void prv_record_reboot_reason(eMemfaultRebootReason reboot_reg_reason,
118-
eMemfaultRebootReason prior_stored_reason) {
118+
uint32_t prior_stored_reason) {
119119
s_reboot_reason_data.reboot_reg_reason = reboot_reg_reason;
120120

121121
if (prior_stored_reason != (eMemfaultRebootReason)MEMFAULT_REBOOT_REASON_NOT_SET) {
122-
s_reboot_reason_data.prior_stored_reason = prior_stored_reason;
122+
s_reboot_reason_data.prior_stored_reason = (eMemfaultRebootReason)prior_stored_reason;
123123
} else {
124124
s_reboot_reason_data.prior_stored_reason = reboot_reg_reason;
125125
}

components/demo/src/memfault_demo_shell_commands.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
//! @brief
77
//! Command definitions for the minimal shell/console implementation.
88

9-
#include "memfault/demo/shell_commands.h"
10-
119
#include <stddef.h>
1210

1311
#include "memfault/core/compiler.h"
1412
#include "memfault/core/data_export.h"
1513
#include "memfault/core/debug_log.h"
1614
#include "memfault/core/math.h"
1715
#include "memfault/demo/cli.h"
16+
#include "memfault/demo/shell_commands.h"
1817

1918
static int prv_panics_component_required(void) {
2019
MEMFAULT_LOG_RAW("Disabled. panics component integration required");
@@ -44,28 +43,37 @@ int memfault_demo_cli_cmd_export(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char
4443

4544
static const sMemfaultShellCommand s_memfault_shell_commands[] = {
4645
{"clear_core", memfault_demo_cli_cmd_clear_core, "Clear an existing coredump"},
47-
{"drain_chunks", memfault_demo_drain_chunk_data, "Flushes queued Memfault data. To upload data see https://mflt.io/posting-chunks-with-gdb"},
48-
{"export", memfault_demo_cli_cmd_export, "Export base64-encoded chunks. To upload data see https://mflt.io/chunk-data-export"},
46+
{"drain_chunks", memfault_demo_drain_chunk_data,
47+
"Flushes queued Memfault data. To upload data see https://mflt.io/posting-chunks-with-gdb"},
48+
{"export", memfault_demo_cli_cmd_export,
49+
"Export base64-encoded chunks. To upload data see https://mflt.io/chunk-data-export"},
4950
{"get_core", memfault_demo_cli_cmd_get_core, "Get coredump info"},
5051
{"get_device_info", memfault_demo_cli_cmd_get_device_info, "Get device info"},
5152

5253
//
5354
// Test commands for validating SDK functionality: https://mflt.io/mcu-test-commands
5455
//
5556

56-
{"test_assert", memfault_demo_cli_cmd_assert, "Trigger memfault assert"},
57+
{"test_assert", memfault_demo_cli_cmd_assert, "Trigger memfault assert"},
58+
59+
#if MEMFAULT_COMPILER_ARM_CORTEX_M
60+
{"test_busfault", memfault_demo_cli_cmd_busfault, "Trigger a busfault"},
61+
{"test_hardfault", memfault_demo_cli_cmd_hardfault, "Trigger a hardfault"},
62+
{"test_memmanage", memfault_demo_cli_cmd_memmanage, "Trigger a memory management fault"},
63+
{"test_usagefault", memfault_demo_cli_cmd_usagefault, "Trigger a usage fault"},
64+
#endif
5765

58-
#if MEMFAULT_COMPILER_ARM
59-
{"test_busfault", memfault_demo_cli_cmd_busfault, "Trigger a busfault"},
60-
{"test_hardfault", memfault_demo_cli_cmd_hardfault, "Trigger a hardfault"},
61-
{"test_memmanage", memfault_demo_cli_cmd_memmanage, "Trigger a memory management fault"},
62-
{"test_usagefault", memfault_demo_cli_cmd_usagefault, "Trigger a usage fault"},
66+
#if MEMFAULT_COMPILER_ARM_V7_A_R
67+
{"test_dataabort", memfault_demo_cli_cmd_dataabort, "Trigger a data abort"},
68+
{"test_prefetchabort", memfault_demo_cli_cmd_prefetchabort, "Trigger a prefetch abort"},
6369
#endif
6470

6571
{"test_log", memfault_demo_cli_cmd_test_log, "Writes test logs to log buffer"},
66-
{"test_log_capture", memfault_demo_cli_cmd_trigger_logs, "Trigger capture of current log buffer contents"},
67-
{"test_reboot", memfault_demo_cli_cmd_system_reboot, "Force system reset and track it with a trace event"},
68-
{"test_trace", memfault_demo_cli_cmd_trace_event_capture, "Capture an example trace event"},
72+
{"test_log_capture", memfault_demo_cli_cmd_trigger_logs,
73+
"Trigger capture of current log buffer contents"},
74+
{"test_reboot", memfault_demo_cli_cmd_system_reboot,
75+
"Force system reset and track it with a trace event"},
76+
{"test_trace", memfault_demo_cli_cmd_trace_event_capture, "Capture an example trace event"},
6977

7078
{"help", memfault_shell_help_handler, "Lists all commands"},
7179
};

components/demo/src/panics/memfault_demo_panics.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int memfault_demo_cli_cmd_assert(int argc, char *argv[]) {
121121
}
122122
}
123123

124-
#if MEMFAULT_COMPILER_ARM
124+
#if MEMFAULT_COMPILER_ARM_CORTEX_M
125125

126126
int memfault_demo_cli_cmd_hardfault(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char *argv[]) {
127127
memfault_arch_disable_configurable_faults();
@@ -178,4 +178,25 @@ int memfault_demo_cli_loadaddr(int argc, char *argv[]) {
178178
return 0;
179179
}
180180

181-
#endif /* MEMFAULT_COMPILER_ARM */
181+
#endif // MEMFAULT_COMPILER_ARM_CORTEX_M
182+
183+
#if MEMFAULT_COMPILER_ARM_V7_A_R
184+
185+
int memfault_demo_cli_cmd_dataabort(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char *argv[]) {
186+
// try to write to a read-only address
187+
volatile int explode = *(int *)0xFFFFFFFF;
188+
189+
return explode | 1;
190+
}
191+
192+
int memfault_demo_cli_cmd_prefetchabort(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char *argv[]) {
193+
// We can trip a PrefetchAbort exception by simply attempting to execute any addresss >=
194+
// 0xE000.0000
195+
void (*bad_func)(void) = (void (*)(void))0xEEEEDEAD;
196+
bad_func();
197+
198+
// We should never get here -- platforms PrefetchAbort handler should be tripped
199+
return -1;
200+
}
201+
202+
#endif // MEMFAULT_COMPILER_ARM_V7_A_R

components/include/memfault/core/compiler.h

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,44 @@ extern "C" {
2121
// (i.e MEMFAULT_STATIC_STRLEN("abcd") == 4)
2222
#define MEMFAULT_STATIC_STRLEN(s) (sizeof(s) - 1)
2323

24-
// A convenience macro that can be checked to see if the current compiler being used targets an
25-
// ARM-based architecture
24+
// Convenience macros for distinguishing ARM variants
2625
#if defined(__arm__) || defined(__ICCARM__) || defined(__TI_ARM__)
27-
#define MEMFAULT_COMPILER_ARM 1
26+
#define MEMFAULT_COMPILER_ARM 1
2827
#else
29-
#define MEMFAULT_COMPILER_ARM 0
28+
#define MEMFAULT_COMPILER_ARM 0
29+
#endif
30+
31+
// Check for ARMv7-A/R target architecture
32+
#if MEMFAULT_COMPILER_ARM
33+
#if defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7A__)
34+
#define MEMFAULT_COMPILER_ARM_V7_A_R 1
35+
#else
36+
#define MEMFAULT_COMPILER_ARM_V7_A_R 0
37+
#endif
38+
39+
// If not Cortex-A/R, select Cortex-M family
40+
#define MEMFAULT_COMPILER_ARM_CORTEX_M !MEMFAULT_COMPILER_ARM_V7_A_R
41+
#else
42+
#define MEMFAULT_COMPILER_ARM_V7_A_R 0
43+
#define MEMFAULT_COMPILER_ARM_CORTEX_M 0
3044
#endif
3145

3246
//
3347
// Pick up compiler specific macro definitions
3448
//
3549

3650
#if defined(__CC_ARM)
37-
#include "compiler_armcc.h"
51+
#include "compiler_armcc.h"
3852
#elif defined(__TI_ARM__)
39-
#include "compiler_ti_arm.h"
53+
#include "compiler_ti_arm.h"
4054
#elif defined(__GNUC__) || defined(__clang__)
41-
#include "compiler_gcc.h"
55+
#include "compiler_gcc.h"
4256
#elif defined(__ICCARM__)
43-
#include "compiler_iar.h"
57+
#include "compiler_iar.h"
4458
#else
45-
# error "New compiler to add support for!"
59+
#error "New compiler to add support for!"
4660
#endif
4761

48-
4962
#ifdef __cplusplus
5063
}
5164
#endif

components/include/memfault/core/compiler_gcc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extern "C" {
3737
#define MEMFAULT_UNUSED __attribute__((unused))
3838
#define MEMFAULT_USED __attribute__((used))
3939
#define MEMFAULT_WEAK __attribute__((weak))
40-
#define MEMFAULT_PRINTF_LIKE_FUNC(a, b) __attribute__ ((format (printf, a, b)))
40+
#define MEMFAULT_PRINTF_LIKE_FUNC(a, b) __attribute__ ((format (__printf__, a, b)))
4141

4242
//! From https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html,
4343
//! If x is 0, the result is undefined.

components/include/memfault/core/compiler_ti_arm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extern "C" {
3030
#define MEMFAULT_UNUSED __attribute__((unused))
3131
#define MEMFAULT_USED __attribute__((used))
3232
#define MEMFAULT_WEAK __attribute__((weak))
33-
#define MEMFAULT_PRINTF_LIKE_FUNC(a, b) __attribute__ ((format (printf, a, b)))
33+
#define MEMFAULT_PRINTF_LIKE_FUNC(a, b) __attribute__ ((format (__printf__, a, b)))
3434

3535
#define MEMFAULT_CLZ(a) ((a == 0) ? 32UL : (uint32_t)__clz(a))
3636

0 commit comments

Comments
 (0)