Skip to content

Commit 57cf611

Browse files
author
Memfault Inc.
committed
Memfault Firmware SDK 1.11.3 (Build local)
1 parent 65447c9 commit 57cf611

19 files changed

+211
-31
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@ 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.11.3] - 2024-09-05
10+
11+
### :chart_with_upwards_trend: Improvements
12+
13+
- General:
14+
15+
- Improve assert stack unwinding for Clang builds when `-flto` is enabled.
16+
17+
- Zephyr:
18+
19+
- Add a new Kconfig option, `CONFIG_MEMFAULT_SOC_FAMILY_ESP32`, to resolve an
20+
error when referencing the deprecated `CONFIG_SOC_FAMILY_ESP32` Kconfig
21+
(removed in
22+
[Zephyr 3.7.0](https://github.com/zephyrproject-rtos/zephyr/commit/8dc3f856229ce083c956aa301c31a23e65bd8cd8)
23+
as part of Hardware Model V2). This new option is used in the Memfault
24+
Zephyr port to check if an ESP32 SOC is being used.
25+
26+
- Remove references to the deprecated `BOOTLOADER_ESP_IDF` Kconfig symbol in
27+
the Memfault Zephyr port (removed in Zephyr 3.7.0).
28+
929
## [1.11.2] - 2024-08-29
1030

1131
### :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: 9770
2-
GIT COMMIT: ea6fadf472
3-
VERSION: 1.11.2
1+
BUILD ID: local
2+
GIT COMMIT: c29972dd3ef
3+
VERSION: 1.11.3

components/core/src/memfault_heap_stats.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "memfault/core/math.h"
2121
#include "memfault/core/platform/debug_log.h"
2222
#include "memfault/core/platform/overrides.h"
23+
#include "memfault/core/sdk_assert.h"
2324

2425
#define MEMFAULT_HEAP_STATS_VERSION 2
2526

@@ -119,6 +120,12 @@ void memfault_heap_stats_malloc(const void *lr, const void *ptr, size_t size) {
119120
g_memfault_heap_stats.max_in_use_block_count = g_memfault_heap_stats.in_use_block_count;
120121
}
121122
uint16_t new_entry_index = prv_get_new_entry_index();
123+
124+
// Ensure a valid entry index is returned. An invalid index can indicate a concurrency
125+
// misconfiguration. MEMFAULT_HEAP_STATS_MALLOC/FREE must prevent concurrent access via
126+
// memfault_lock/unlock or other means
127+
MEMFAULT_SDK_ASSERT(new_entry_index != MEMFAULT_HEAP_STATS_LIST_END);
128+
122129
sMfltHeapStatEntry *new_entry = &g_memfault_heap_stats_pool[new_entry_index];
123130
*new_entry = (sMfltHeapStatEntry){
124131
.lr = lr,
@@ -165,7 +172,7 @@ void memfault_heap_stats_free(const void *ptr) {
165172
g_memfault_heap_stats.stats_pool_head = entry->info.next_entry_index;
166173
}
167174

168-
// If there's a valid previous entry, set it's next index to removed entry's
175+
// If there's a valid previous entry, set its next index to removed entry's
169176
if (previous_entry_index != MEMFAULT_HEAP_STATS_LIST_END) {
170177
g_memfault_heap_stats_pool[previous_entry_index].info.next_entry_index =
171178
entry->info.next_entry_index;

components/core/src/memfault_ram_reboot_info_tracking.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626

2727
#define MEMFAULT_REBOOT_INFO_VERSION 2
2828

29+
// clang-format off
30+
// Internal value used to initialize sMfltRebootInfo.last_reboot_reason. Care must be taken when
31+
// comparing this value to eMemfaultRebootReason as different platforms produce different behavior
32+
// comparing uint32_t to enum types. In general, cast this value to the type it is compared against.
33+
// Examples:
34+
//
35+
// uint32_t last_reboot_reason != MEMFAULT_REBOOT_REASON_NOT_SET (GOOD)
36+
// eMemfaultRebootReason reboot_reason != (eMemfaultRebootReason)MEMFAULT_REBOOT_REASON_NOT_SET (GOOD)
37+
// uint32_t last_reboot_reason != (eMemfaultRebootReason)MEMFAULT_REBOOT_REASON_NOT_SET (BAD)
38+
// clang-format on
2939
#define MEMFAULT_REBOOT_REASON_NOT_SET 0xffffffff
3040

3141
typedef MEMFAULT_PACKED_STRUCT MfltRebootInfo {
@@ -56,6 +66,10 @@ sMfltRebootInfo;
5666
MEMFAULT_STATIC_ASSERT(sizeof(sMfltRebootInfo) == MEMFAULT_REBOOT_TRACKING_REGION_SIZE,
5767
"struct doesn't match expected size");
5868

69+
MEMFAULT_STATIC_ASSERT(sizeof(eMemfaultRebootReason) <=
70+
sizeof(((sMfltRebootInfo){ 0 }).last_reboot_reason),
71+
"enum does not fit within sMfltRebootInfo.last_reboot_reason");
72+
5973
static sMfltRebootInfo *s_mflt_reboot_info;
6074

6175
//! Struct to retrieve reboot reason data from. Matches the fields of sMfltRebootReason
@@ -90,6 +104,7 @@ static bool prv_check_or_init_struct(void) {
90104
}
91105

92106
static bool prv_read_reset_info(sMfltResetReasonInfo *info) {
107+
// prior_stored_reason is a uint32_t, no need to cast MEMFAULT_REBOOT_REASON_NOT_SET
93108
if ((s_mflt_reboot_info->last_reboot_reason == MEMFAULT_REBOOT_REASON_NOT_SET) &&
94109
(s_mflt_reboot_info->reset_reason_reg0 == 0)) {
95110
return false; // no reset crashes!
@@ -118,7 +133,8 @@ static void prv_record_reboot_reason(eMemfaultRebootReason reboot_reg_reason,
118133
uint32_t prior_stored_reason) {
119134
s_reboot_reason_data.reboot_reg_reason = reboot_reg_reason;
120135

121-
if (prior_stored_reason != (eMemfaultRebootReason)MEMFAULT_REBOOT_REASON_NOT_SET) {
136+
// prior_stored_reason is a uint32_t, no need to cast MEMFAULT_REBOOT_REASON_NOT_SET
137+
if (prior_stored_reason != MEMFAULT_REBOOT_REASON_NOT_SET) {
122138
s_reboot_reason_data.prior_stored_reason = (eMemfaultRebootReason)prior_stored_reason;
123139
} else {
124140
s_reboot_reason_data.prior_stored_reason = reboot_reg_reason;
@@ -131,6 +147,9 @@ static bool prv_get_unexpected_reboot_occurred(void) {
131147
// Use prior_stored_reason as source of reboot reason. Fallback to reboot_reg_reason if
132148
// prior_stored_reason is not set
133149
eMemfaultRebootReason reboot_reason;
150+
151+
// s_reboot_reason_data.prior_stored_reason is an eMemfaultRebootReason type, cast
152+
// MEMFAULT_REBOOT_REASON_NOT_SET
134153
if (s_reboot_reason_data.prior_stored_reason !=
135154
(eMemfaultRebootReason)MEMFAULT_REBOOT_REASON_NOT_SET) {
136155
reboot_reason = s_reboot_reason_data.prior_stored_reason;
@@ -151,6 +170,7 @@ static void prv_record_reboot_event(eMemfaultRebootReason reboot_reason,
151170
// s_mflt_reboot_info can be cleared by any call to memfault_reboot_tracking_collect_reset_info
152171
prv_record_reboot_reason(reboot_reason, s_mflt_reboot_info->last_reboot_reason);
153172

173+
// last_reboot_reason is a uint32_t, no need to cast MEMFAULT_REBOOT_REASON_NOT_SET
154174
if (s_mflt_reboot_info->last_reboot_reason != MEMFAULT_REBOOT_REASON_NOT_SET) {
155175
// we are already tracking a reboot. We don't overwrite this because generally the first reboot
156176
// in a loop reveals what started the crash loop

components/include/memfault/core/reboot_tracking.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ typedef struct MfltRebootType {
6363
eMemfaultRebootReason prior_stored_reason;
6464
} sMfltRebootReason;
6565

66-
//! Value used to determine state of reboot tracking data
67-
#define MEMFAULT_REBOOT_REASON_NOT_SET 0xffffffff
68-
6966
#define MEMFAULT_REBOOT_TRACKING_REGION_SIZE 64
7067

7168
//! Sets the memory region used for reboot tracking.

components/include/memfault/panics/fault_handling.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ MEMFAULT_NAKED_FUNC void MEMFAULT_EXC_HANDLER_WATCHDOG(void);
8282
//! @param lr The return address
8383
//! @see MEMFAULT_ASSERT_RECORD
8484
//! @see MEMFAULT_ASSERT
85-
#if defined(__CC_ARM) || defined(__ICCARM__) || (defined(__clang__) && defined(__ti__))
86-
//! ARMCC, IAR, and tiarmclang will optimize away link register stores from callsites which makes it
87-
//! impossible for a reliable backtrace to be resolved so we don't use the NORETURN attribute
85+
#if defined(__CC_ARM) || defined(__ICCARM__) || defined(__clang__)
86+
//! ARMCC, IAR, and clang (include tiarmclang) will optimize away link register stores from
87+
//! callsites which makes it impossible for a reliable backtrace to be resolved so we don't use the
88+
//! NORETURN attribute
8889
#else
8990
MEMFAULT_NORETURN
9091
#endif
@@ -97,9 +98,10 @@ void memfault_fault_handling_assert(void *pc, void *lr);
9798
//! @param extra_info Additional information used by the assert handler
9899
//! @see MEMFAULT_ASSERT_RECORD
99100
//! @see MEMFAULT_ASSERT
100-
#if defined(__CC_ARM) || defined(__ICCARM__) || (defined(__clang__) && defined(__ti__))
101-
//! ARMCC, IAR, and tiarmclang optimize away link register stores from callsites which makes it
102-
//! impossible for a reliable backtrace to be resolved so we don't use the NORETURN attribute
101+
#if defined(__CC_ARM) || defined(__ICCARM__) || defined(__clang__)
102+
//! ARMCC, IAR, and clang (include tiarmclang) will optimize away link register stores from
103+
//! callsites which makes it impossible for a reliable backtrace to be resolved so we don't use the
104+
//! NORETURN attribute
103105
#else
104106
MEMFAULT_NORETURN
105107
#endif

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 = 11, .patch = 2 }
23-
#define MEMFAULT_SDK_VERSION_STR "1.11.2"
22+
#define MEMFAULT_SDK_VERSION { .major = 1, .minor = 11, .patch = 3 }
23+
#define MEMFAULT_SDK_VERSION_STR "1.11.3"
2424

2525
#ifdef __cplusplus
2626
}

components/panics/src/memfault_fault_handling_arm.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,13 @@ void MEMFAULT_ASSERT_TRAP(void) {
553553
#define MEMFAULT_ASSERT_TRAP() __asm volatile("udf #77")
554554
#endif
555555

556-
static void prv_fault_handling_assert(void *pc, void *lr, eMemfaultRebootReason reason) {
556+
#if defined(__clang__)
557+
// When using clang with LTO, the compiler can optimize storing the LR + FP from this function,
558+
// disable optimizations to fix
559+
MEMFAULT_NO_OPT
560+
#endif
561+
static void
562+
prv_fault_handling_assert(void *pc, void *lr, eMemfaultRebootReason reason) {
557563
// Only set the crash reason if it's unset, in case we are in a nested assert
558564
if (s_crash_reason == kMfltRebootReason_Unknown) {
559565
sMfltRebootTrackingRegInfo info = {

components/panics/src/memfault_fault_handling_riscv.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ void memfault_arch_fault_handling_assert(void *pc, void *lr, eMemfaultRebootReas
4545

4646
// For non-esp-idf riscv implementations, provide a full assert handler and
4747
// other utilities.
48-
#if defined(__ZEPHYR__) && \
49-
(defined(CONFIG_SOC_FAMILY_ESP32) || defined(CONFIG_SOC_FAMILY_ESPRESSIF_ESP32))
48+
#if defined(__ZEPHYR__) && (defined(CONFIG_MEMFAULT_SOC_FAMILY_ESP32))
5049
#include <hal/cpu_hal.h>
5150
#include <zephyr/kernel.h>
5251

components/panics/src/memfault_fault_handling_xtensa.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ void memfault_arch_fault_handling_assert(void *pc, void *lr, eMemfaultRebootReas
4242

4343
// For Zephyr Xtensa, provide an assert handler and other utilities.
4444
// The Kconfig for the ESP32 family changed in v3.7.0. Support both Kconfigs
45-
#if defined(__ZEPHYR__) && \
46-
(defined(CONFIG_SOC_FAMILY_ESP32) || defined(CONFIG_SOC_FAMILY_ESPRESSIF_ESP32))
45+
#if defined(__ZEPHYR__) && (defined(CONFIG_MEMFAULT_SOC_FAMILY_ESP32))
4746
#include <hal/cpu_hal.h>
4847
#include <zephyr/kernel.h>
4948

0 commit comments

Comments
 (0)