Skip to content

Commit 0bd360f

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.18.0 (Build 11548)
1 parent 053865f commit 0bd360f

20 files changed

+253
-108
lines changed

CHANGELOG.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ 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.18.0] - 2024-11-25
10+
11+
### 📈 Added
12+
13+
- General:
14+
15+
- Add a new built-in metric, `uptime_s`, which reports the total uptime of the
16+
device in seconds. This metrics is enabled by default, and can be disabled
17+
with `#define MEMFAULT_METRICS_UPTIME_ENABLE 0` in
18+
`memfault_platform_config.h`.
19+
20+
- Zephyr:
21+
22+
- Update the [QEMU sample app](examples/zephyr/qemu) to use newly-released
23+
Zephyr v4.0.0 🥳.
24+
25+
- ESP-IDF:
26+
27+
- Added support for dual-core coredumps on ESP32 and ESP32-S3. This feature is
28+
enabled by default and can be disabled with the Kconfig option
29+
`CONFIG_MEMFAULT_COREDUMP_CPU_COUNT=1`. Note: not all fault conditions will
30+
cause both CPU cores to be captured in the coredump. The SDK will always
31+
capture the core that triggered the fault, and if the non-faulting core is
32+
available for capture, it will be included as well.
33+
934
## [1.17.0] - 2024-11-14
1035

1136
### 📈 Added
@@ -43,16 +68,16 @@ and this project adheres to
4368
# Before:
4469
mflt> test_log
4570
Raw log!
46-
2024-11-14T17:01:12Z|4284 I Info log!
47-
2024-11-14T17:01:12Z|4284 W Warning log!
48-
2024-11-14T17:01:12Z|4284 E Error log!
71+
MFLT:[INFO] Info log!
72+
MFLT:[WARN] Warning log!
73+
MFLT:[ERRO] Error log!
4974

5075
# After:
5176
mflt> test_log
5277
Raw log!
53-
MFLT:[INFO] Info log!
54-
MFLT:[WARN] Warning log!
55-
MFLT:[ERRO] Error log!
78+
2024-11-14T17:01:12Z|4284 I Info log!
79+
2024-11-14T17:01:12Z|4284 W Warning log!
80+
2024-11-14T17:01:12Z|4284 E Error log!
5681
```
5782

5883
- ESP-IDF:

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
BUILD ID: 11353
2-
GIT COMMIT: 767ed66f9e
3-
VERSION: 1.17.0
1+
BUILD ID: 11548
2+
GIT COMMIT: 045729d525
3+
VERSION: 1.18.0

components/include/memfault/default_config.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ extern "C" {
8484
#define MEMFAULT_COREDUMP_INCLUDE_BUILD_ID 1
8585
#endif
8686

87+
//! Some architectures will support multiple cores. This is used by the
88+
//! architecture-specific coredump handling code to determine how many
89+
//! register sets to save.
90+
#ifndef MEMFAULT_COREDUMP_CPU_COUNT
91+
#define MEMFAULT_COREDUMP_CPU_COUNT 1
92+
#endif
93+
8794
//! Controls the truncation of the Build Id that is encoded in events
8895
//!
8996
//! The full Build Id hash is 20 bytes, but is truncated by default to save space. The
@@ -347,6 +354,11 @@ extern "C" {
347354
#define MEMFAULT_METRICS_LOGS_ENABLE 1
348355
#endif
349356

357+
//! Enable built in uptime metric tracking
358+
#ifndef MEMFAULT_METRICS_UPTIME_ENABLE
359+
#define MEMFAULT_METRICS_UPTIME_ENABLE 1
360+
#endif
361+
350362
//! Disable Metrics Sessions at compile time. This saves a small amount of
351363
//! memory but prevents the use of Metrics Sessions.
352364
#ifndef MEMFAULT_METRICS_SESSIONS_ENABLED

components/include/memfault/metrics/heartbeat_config.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ MEMFAULT_METRICS_KEY_DEFINE_WITH_SCALE_VALUE(battery_soc_pct, kMemfaultMetricTyp
4242
MEMFAULT_METRICS_KEY_DEFINE(MemfaultSDKMetric_log_dropped_lines, kMemfaultMetricType_Unsigned)
4343
MEMFAULT_METRICS_KEY_DEFINE(MemfaultSDKMetric_log_recorded_lines, kMemfaultMetricType_Unsigned)
4444
#endif
45+
46+
#if MEMFAULT_METRICS_UPTIME_ENABLE
47+
MEMFAULT_METRICS_KEY_DEFINE(uptime_s, kMemfaultMetricType_Unsigned)
48+
#endif

components/include/memfault/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ typedef struct {
2020
} sMfltSdkVersion;
2121

2222
#define MEMFAULT_SDK_VERSION \
23-
{ .major = 1, .minor = 17, .patch = 0 }
24-
#define MEMFAULT_SDK_VERSION_STR "1.17.0"
23+
{ .major = 1, .minor = 18, .patch = 0 }
24+
#define MEMFAULT_SDK_VERSION_STR "1.18.0"
2525

2626
#ifdef __cplusplus
2727
}

components/metrics/src/memfault_metrics.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,9 @@ static void prv_collect_builtin_data(void) {
555555
#if MEMFAULT_METRICS_LOGS_ENABLE
556556
prv_memfault_collect_log_metrics();
557557
#endif
558+
#if MEMFAULT_METRICS_UPTIME_ENABLE
559+
MEMFAULT_METRIC_SET_UNSIGNED(uptime_s, memfault_platform_get_time_since_boot_ms() / 1000);
560+
#endif
558561
}
559562

560563
// Returns NULL if not a timer type or out of bounds index.

components/panics/src/memfault_coredump.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,24 @@ static bool prv_write_coredump_sections(const sMemfaultCoredumpSaveInfo *save_in
477477
const void *regs = save_info->regs;
478478
const size_t regs_size = save_info->regs_size;
479479
if (regs != NULL) {
480+
#if MEMFAULT_COREDUMP_CPU_COUNT == 1
480481
if (!prv_write_non_memory_block(kMfltCoredumpBlockType_CurrentRegisters, regs, regs_size,
481482
&write_ctx)) {
482483
return false;
483484
}
485+
#else
486+
// If we have multiple CPUs, we need to save the registers for each CPU.
487+
// save_info->regs is an array of CPU0, CPU1, etc. registers.
488+
for (size_t i = 0; i < MEMFAULT_COREDUMP_CPU_COUNT; i++) {
489+
const size_t cpu_regs_size = regs_size / MEMFAULT_COREDUMP_CPU_COUNT;
490+
const uint32_t *cpu_regs = (const uint32_t *)((const uintptr_t)regs + (i * cpu_regs_size));
491+
492+
if (!prv_write_non_memory_block(kMfltCoredumpBlockType_CurrentRegisters, cpu_regs,
493+
cpu_regs_size, &write_ctx)) {
494+
return false;
495+
}
496+
}
497+
#endif
484498
}
485499

486500
if (!prv_write_device_info_blocks(&write_ctx)) {

components/panics/src/memfault_fault_handling_xtensa.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,34 @@ MEMFAULT_NO_OPT void memfault_fault_handling_assert(void *pc, void *lr) {
9999
#error "Unsupported Xtensa platform. Please visit https://mflt.io/contact-support"
100100
#endif // !defined(ESP_PLATFORM) && defined(__ZEPHYR__)
101101

102+
#if MEMFAULT_COREDUMP_CPU_COUNT > 1
103+
#if defined(__ZEPHYR__)
104+
#error "Dual-core support not yet implemented for Zephyr Xtensa"
105+
#else
106+
#include "esp_cpu.h"
107+
108+
#endif
109+
110+
static int prv_get_current_cpu_id(void) {
111+
return esp_cpu_get_core_id();
112+
}
113+
#endif // MEMFAULT_COREDUMP_CPU_COUNT == 1
114+
102115
void memfault_fault_handler(const sMfltRegState *regs, eMemfaultRebootReason reason) {
116+
#if MEMFAULT_COREDUMP_CPU_COUNT == 1
117+
const sMfltRegState *current_cpu_regs = regs;
118+
#else
119+
const int cpu_id = prv_get_current_cpu_id();
120+
const sMfltRegState *current_cpu_regs = &regs[cpu_id];
121+
#endif
103122
if (s_crash_reason == kMfltRebootReason_Unknown) {
104123
// skip LR saving here.
105-
prv_fault_handling_assert((void *)regs->pc, (void *)0, reason);
124+
prv_fault_handling_assert((void *)current_cpu_regs->pc, (void *)0, reason);
106125
}
107126

108127
sMemfaultCoredumpSaveInfo save_info = {
109128
.regs = regs,
110-
.regs_size = sizeof(*regs),
129+
.regs_size = sizeof(*regs) * MEMFAULT_COREDUMP_CPU_COUNT,
111130
.trace_reason = s_crash_reason,
112131
};
113132

@@ -122,7 +141,7 @@ void memfault_fault_handler(const sMfltRegState *regs, eMemfaultRebootReason rea
122141
// For the windowed ABI, a1 always holds the current "sp":
123142
// https://github.com/espressif/esp-idf/blob/v4.0/components/freertos/readme_xtensa.txt#L421-L428
124143
const uint32_t windowed_abi_spill_size = 64;
125-
const uint32_t sp_prior_to_exception = regs->a[1] - windowed_abi_spill_size;
144+
const uint32_t sp_prior_to_exception = current_cpu_regs->a[1] - windowed_abi_spill_size;
126145

127146
sCoredumpCrashInfo info = {
128147
.stack_address = (void *)sp_prior_to_exception,
@@ -139,7 +158,7 @@ void memfault_fault_handler(const sMfltRegState *regs, eMemfaultRebootReason rea
139158

140159
size_t memfault_coredump_storage_compute_size_required(void) {
141160
// actual values don't matter since we are just computing the size
142-
sMfltRegState core_regs = { 0 };
161+
sMfltRegState core_regs[MEMFAULT_COREDUMP_CPU_COUNT] = { 0 };
143162
sMemfaultCoredumpSaveInfo save_info = {
144163
.regs = &core_regs,
145164
.regs_size = sizeof(core_regs),

examples/zephyr/qemu/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ the following commands to test the application:
2222
❯ west build qemu-app
2323
❯ west build --target run
2424

25-
*** Booting Zephyr OS build zephyr-v3.2.0 ***
25+
*** Booting Zephyr OS build zephyr-v4.0.0 ***
2626
[00:00:00.000,000] <inf> mflt: GNU Build ID: 4ffb5879ed5923582035133086015bbf65504364
2727
[00:00:00.000,000] <inf> main: 👋 Memfault Demo App! Board qemu_cortex_m3
2828

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ manifest:
1313
projects:
1414
- name: zephyr
1515
remote: zephyrproject-rtos
16-
revision: v3.7.0
16+
revision: v4.0.0
1717
import:
1818
# Limit the Zephyr modules to the required set
1919
name-allowlist:

ports/esp_idf/memfault/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ endif
103103
'memfault_platform_coredump_storage_get_info()' function to return
104104
the threshold value set here as the size of the partition..
105105

106+
config MEMFAULT_COREDUMP_CPU_COUNT
107+
int "Number of CPU cores to include in coredumps"
108+
default SOC_CPU_CORES_NUM
109+
# Symbolic values in the range are not supported by
110+
# confgen.py/esp-idf-kconfig until later versions (esp-idf 5+). Hard
111+
# code to a max of 2.
112+
range 1 2
113+
help
114+
The number of CPU cores to include in coredumps. By default, all
115+
cores are included.
116+
106117
config MEMFAULT_AUTOMATIC_INIT
107118
bool "[DEPRECATED] Automatically initialize the SDK when the system is booted"
108119
default n

0 commit comments

Comments
 (0)