Skip to content

Commit 5a265a6

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 0.33.4 (Build 518181)
1 parent 0fc9185 commit 5a265a6

File tree

5 files changed

+34
-5
lines changed

5 files changed

+34
-5
lines changed

CHANGES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
### Changes between Memfault SDK 0.33.3 and SDK 0.33.4 - Sept 15, 2022
2+
3+
#### :chart_with_upwards_trend: Improvements
4+
5+
- Zephyr port updates:
6+
- Handle thread abort in the task stack capture hook. Previous to this change,
7+
aborted tasks would remain on the captured task list, and restarting the
8+
task would create a duplicate entry.
9+
110
### Changes between Memfault SDK 0.33.2 and SDK 0.33.3 - Sept 14, 2022
211

312
#### :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: 517561
2-
GIT COMMIT: a436bb3d2
1+
BUILD ID: 518181
2+
GIT COMMIT: 091f1bf24

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 = 33, .patch = 3 }
22+
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 33, .patch = 4 }
2323

2424
#ifdef __cplusplus
2525
}

ports/zephyr/common/memfault_zephyr_ram_regions.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ static bool prv_find_slot(size_t *idx, struct k_thread *desired_tcb) {
3737

3838
// We intercept calls to arch_new_thread() so we can track when new tasks
3939
// are created
40+
//
41+
// It would be nice to use '__builtin_types_compatible_p' and '__typeof__' to
42+
// enforce strict abi matching in the wrapped functions, but the target
43+
// functions are declared in private zephyr ./kernel/include files, which are
44+
// not really supposed to be accessed from user code and would require some
45+
// dubious path hacks to get to.
4046
void __wrap_arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
4147
char *stack_ptr, k_thread_entry_t entry,
4248
void *p1, void *p2, void *p3);
@@ -56,6 +62,19 @@ void __wrap_arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
5662
__real_arch_new_thread(thread, stack, stack_ptr, entry, p1, p2, p3);
5763
}
5864

65+
void __wrap_z_thread_abort(struct k_thread *thread);
66+
void __real_z_thread_abort(struct k_thread *thread);
67+
68+
void __wrap_z_thread_abort(struct k_thread *thread) {
69+
size_t idx = 0;
70+
const bool slot_found = prv_find_slot(&idx, thread);
71+
if (slot_found) {
72+
s_task_tcbs[idx] = EMPTY_SLOT;
73+
}
74+
75+
__real_z_thread_abort(thread);
76+
}
77+
5978
MEMFAULT_WEAK
6079
size_t memfault_platform_sanitize_address_range(void *start_addr, size_t desired_size) {
6180
// NB: This only works for MCUs which have a contiguous RAM address range. (i.e Any MCU in the

ports/zephyr/v2.4/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ zephyr_include_directories(.)
1414
# Memfault fault handler which will collect a coredump.
1515
target_link_libraries(app INTERFACE "-Wl,--wrap=z_fatal_error")
1616

17-
# We trace task creation so the task TCBs and stacks can be collected at the time
18-
# of a crash and all thread backtraces can be made available in the Memfault UI.
17+
# We trace task creation and deletion so the task TCBs and stacks can be collected at the time of a
18+
# crash and all thread backtraces can be made available in the Memfault UI.
1919
#
2020
# To do this we wrap the arch_new_thread() function call that is made from thread.c
2121
#
2222
# A nicer way to do this would be to make use of the "sys_trace_thread_create" macro.
2323
# Unfortunately, to override the macro, one must patch the Zephyr RTOS today.
2424
# https://github.com/zephyrproject-rtos/zephyr/blob/390537b/include/tracing/tracing.h#L57-L61
2525
target_link_libraries(app INTERFACE "-Wl,--wrap=arch_new_thread")
26+
target_link_libraries(app INTERFACE "-Wl,--wrap=z_thread_abort")

0 commit comments

Comments
 (0)