Skip to content

Commit 130dc3a

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.9.1 (Build 7915)
1 parent 0005373 commit 130dc3a

File tree

9 files changed

+121
-18
lines changed

9 files changed

+121
-18
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 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.9.1] - 2024-05-21
10+
11+
### :chart_with_upwards_trend: Improvements
12+
13+
- ESP-IDF:
14+
15+
- Fix an issue with the Memfault ESP-IDF integration to support the newly
16+
released ESP-IDF v5.1.4.
17+
18+
- Zephyr:
19+
20+
- Add support for tracking ESP32 reboots in `.rtc_noinit` section. This
21+
improves tracking of the OTA [Reboot Reason](https://mflt.io/reboot-reasons)
22+
when the device reboots after an OTA update.
23+
24+
- Fix compilation warnings when
25+
`CONFIG_MEMFAULT_COREDUMP_FULL_THREAD_STACKS=y` is enabled. Thanks to @fouge
26+
for providing this fix in
27+
[#70](https://github.com/memfault/memfault-firmware-sdk/pull/70) 🎉!
28+
29+
- General:
30+
31+
- Extend [`eclipse_patch.py`](scripts/eclipse_patch.py) to support adding the
32+
Memfault SDK files to an STM32Cube IDE project.
33+
934
## [1.9.0] - 2024-05-10
1035

1136
### :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: 7848
2-
GIT COMMIT: e5e934d26b
3-
VERSION: 1.9.0
1+
BUILD ID: 7915
2+
GIT COMMIT: 435dc7c1d8
3+
VERSION: 1.9.1

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 = 9, .patch = 0 }
23-
#define MEMFAULT_SDK_VERSION_STR "1.9.0"
22+
#define MEMFAULT_SDK_VERSION { .major = 1, .minor = 9, .patch = 1 }
23+
#define MEMFAULT_SDK_VERSION_STR "1.9.1"
2424

2525
#ifdef __cplusplus
2626
}

ports/esp_idf/memfault/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,14 @@ endif()
291291
# Much more flexibility in debug information collected (e.g. all RAM, just the current stack trace, select stacks and variables)
292292
# Data can be posted directly from device to Memfault cloud for deduplication and analysis
293293
#
294-
# Note: in ESP-IDF v5.3.0, the core dump handler function was renamed from esp_core_dump_to_flash to esp_core_dump_write
295294
set(panic_handler_args "")
296295
if (DEFINED ENV{IDF_VERSION})
297-
if ($ENV{IDF_VERSION} VERSION_GREATER_EQUAL "5.3.0")
296+
# In ESP-IDF v5.3.0, the core dump handler function was renamed from
297+
# esp_core_dump_to_flash to esp_core_dump_write. It was backported to v5.2.2.
298+
if ($ENV{IDF_VERSION} VERSION_GREATER_EQUAL "5.2.2")
299+
list(APPEND panic_handler_args "-Wl,--wrap=esp_core_dump_write")
300+
# Backported to v5.1.4
301+
elseif(($ENV{IDF_VERSION} VERSION_GREATER_EQUAL "5.1.4") AND ($ENV{IDF_VERSION} VERSION_LESS "5.2.0"))
298302
list(APPEND panic_handler_args "-Wl,--wrap=esp_core_dump_write")
299303
else()
300304
list(APPEND panic_handler_args "-Wl,--wrap=esp_core_dump_to_flash")

ports/esp_idf/memfault/common/memfault_fault_handler.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ void memfault_fault_handling_assert_extra(void *pc, void *lr, sMemfaultAssertInf
9595
//! later backported to the 4.2 branch in v4.2.3. Support that change with a
9696
//! version check (see static assert below for verifying the signature is
9797
//! correct).
98-
//! The signature also changed in esp-idf v5.3.0.
98+
//! The signature changed in esp-idf v5.3.0, back ported to v5.1.4 + v5.2.2.
9999
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 3)
100-
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
100+
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 2)) || \
101+
((ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 4)) && \
102+
(ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)))
101103
void __wrap_esp_core_dump_write(panic_info_t *info) {
102104
#else
103105
void __wrap_esp_core_dump_to_flash(panic_info_t *info) {
@@ -253,7 +255,9 @@ void __wrap_esp_core_dump_to_flash(XtExcFrame *fp) {
253255

254256
// Ensure the substituted function signature matches the original function
255257
_Static_assert(__builtin_types_compatible_p(
256-
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
258+
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 2)) || \
259+
((ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 4)) && \
260+
(ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)))
257261
__typeof__(&esp_core_dump_write), __typeof__(&__wrap_esp_core_dump_write)),
258262
#else
259263
__typeof__(&esp_core_dump_to_flash), __typeof__(&__wrap_esp_core_dump_to_flash)),

ports/zephyr/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,14 @@ config MEMFAULT_REBOOT_REASON_GET_CUSTOM
381381
User of SDK must provide their own implementation of memfault_reboot_reason_get()
382382
when disabled
383383

384+
config MEMFAULT_REBOOT_TRACKING_REGION
385+
string "Memfault Reboot Tracking Region"
386+
default ".rtc_noinit" if SOC_FAMILY_ESP32
387+
default ".noinit.mflt_reboot_info"
388+
help
389+
The region in memory where the reboot tracking information will be stored.
390+
This region should be marked as NOINIT in the linker script.
391+
384392
config MEMFAULT_CLEAR_RESET_REG
385393
bool "Whether or not to clear bits in MCU reset reason register"
386394
default y

ports/zephyr/common/memfault_platform_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void assert_post_action(const char *file, unsigned int line)
9797
// On boot-up, log out any information collected as to why the
9898
// reset took place
9999

100-
MEMFAULT_PUT_IN_SECTION(".noinit.mflt_reboot_info")
100+
MEMFAULT_PUT_IN_SECTION(CONFIG_MEMFAULT_REBOOT_TRACKING_REGION)
101101
static uint8_t s_reboot_tracking[MEMFAULT_REBOOT_TRACKING_REGION_SIZE];
102102

103103
static uint8_t s_event_storage[CONFIG_MEMFAULT_EVENT_STORAGE_SIZE];

ports/zephyr/common/memfault_zephyr_ram_regions.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ size_t memfault_zephyr_get_task_regions(sMfltCoredumpRegion *regions, size_t num
191191
// region, so we might be duplicating it here; it's a little wasteful, but
192192
// it's good to always prioritize the currently running stack, in case the
193193
// coredump is truncated due to lack of space.
194-
#if !CONFIG_MEMFAULT_COREDUMP_FULL_THREAD_STACKS
194+
#if !defined(CONFIG_MEMFAULT_COREDUMP_FULL_THREAD_STACKS)
195195
if ((uintptr_t)_kernel.cpus[0].current == (uintptr_t)thread) {
196196
// when collecting partial stacks, thread context is only valid when task
197197
// is _not_ running so we skip collecting it. just update the watermark
@@ -217,16 +217,15 @@ size_t memfault_zephyr_get_task_regions(sMfltCoredumpRegion *regions, size_t num
217217
;
218218

219219
#if defined(CONFIG_THREAD_STACK_INFO)
220+
#if defined(CONFIG_MEMFAULT_COREDUMP_FULL_THREAD_STACKS)
221+
// Capture the entire stack for this thread
222+
size_t stack_size_to_collect = thread->stack_info.size;
223+
sp = (void *)thread->stack_info.start;
224+
#else
220225
// We know where the top of the stack is. Use that information to shrink
221226
// the area we need to collect if less than CONFIG_MEMFAULT_COREDUMP_STACK_SIZE_TO_COLLECT
222227
// is in use
223228
const uint32_t stack_top = thread->stack_info.start + thread->stack_info.size;
224-
225-
#if CONFIG_MEMFAULT_COREDUMP_FULL_THREAD_STACKS
226-
// Capture the entire stack for this thread
227-
size_t stack_size_to_collect = thread->stack_info.size;
228-
sp = thread->stack_info.start;
229-
#else
230229
size_t stack_size_to_collect =
231230
MEMFAULT_MIN(stack_top - (uint32_t)sp, CONFIG_MEMFAULT_COREDUMP_STACK_SIZE_TO_COLLECT);
232231
#endif

scripts/eclipse_patch.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,25 @@ def get_file_element(file_name, virtual_dir, common_prefix, parent_dir, path_typ
8080
return generate_link_element(name, path, path_type=path_type)
8181

8282

83+
def generate_st_linker_option():
84+
ele = ET.fromstring( # noqa: S314
85+
"""
86+
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags" valueType="stringList">
87+
\t\t\t\t\t\t\t\t\t</option>
88+
"""
89+
)
90+
ele.tail = "\n\t\t\t\t\t\t\t\t"
91+
return ele
92+
93+
94+
def generate_st_build_id_flag():
95+
ele = ET.fromstring( # noqa: S314
96+
"""<listOptionValue builtIn="false" value="-Wl,--build-id" />"""
97+
)
98+
ele.tail = "\n\t\t\t\t\t\t\t\tq"
99+
return ele
100+
101+
83102
def recursive_glob_backport(dir_glob):
84103
# Find first directory wildcard and walk the tree from there
85104
glob_root = dir_glob.split("/*")[0]
@@ -272,6 +291,8 @@ def _find_include_nodes(option):
272291
"ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths",
273292
# this is the element id used by NXP's MCUXpresso IDE
274293
"gnu.c.compiler.option.include.paths",
294+
# Element used by ST's STM32Cube IDE for include path enumeration
295+
"com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths",
275296
))
276297

277298
memfault_sdk_include_paths = [
@@ -294,12 +315,54 @@ def _find_include_nodes(option):
294315
ele.tail = tail
295316
include_option.append(ele)
296317

318+
#
319+
# Add GNU build id to STM32Cube IDE based projects
320+
#
321+
322+
def _find_st_linker_tools(tool):
323+
return tool.get("id", "").startswith(
324+
# Element used by ST's STM32Cube IDE for linker arguments
325+
"com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker",
326+
)
327+
328+
def _find_st_linker_options(option):
329+
return option.get("id", "").startswith(
330+
"com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags"
331+
)
332+
333+
def _find_st_build_id_linker_flag(option):
334+
return "--build-id" in option.get("value", "")
335+
336+
tools = root.findall(".//tool")
337+
linker_tools = filter(_find_st_linker_tools, tools)
338+
for linker_tool in linker_tools:
339+
all_linker_options = linker_tool.findall(".//option")
340+
341+
linker_options = filter(_find_st_linker_options, all_linker_options)
342+
if len(list(linker_options)) != 0:
343+
continue
344+
345+
ele = generate_st_linker_option()
346+
linker_tool.insert(0, ele)
347+
348+
# reload all linker options and now add the flag itself
349+
linker_options = filter(_find_st_linker_options, linker_tool.findall(".//option"))
350+
for linker_option in linker_options:
351+
linker_flags = filter(
352+
_find_st_build_id_linker_flag, linker_option.findall(".//listOptionValue")
353+
)
354+
if len(list(linker_flags)) != 0:
355+
continue
356+
ele = generate_st_build_id_flag()
357+
linker_option.insert(0, ele)
358+
297359
#
298360
# Add GNU build id generation for all build configurations:
299361
#
300362

301363
def _find_linker_flags(option):
302364
return option.get("id", "").startswith(
365+
# Element used by Dialog's Smart Snippets Studio IDE
303366
"ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.other"
304367
) and option.get("name", "").startswith("Other linker flags")
305368

0 commit comments

Comments
 (0)