Skip to content

Commit 18b228b

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.7.6 (Build 7230)
1 parent 648e76f commit 18b228b

File tree

14 files changed

+121
-22
lines changed

14 files changed

+121
-22
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ 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.7.6] - 2024-04-03
10+
11+
### :chart_with_upwards_trend: Improvements
12+
13+
- ESP-IDF:
14+
15+
- Fix missing call to `memfault_boot()` in the
16+
[ESP32 example app](examples/esp32) that was causing the device to not boot
17+
correctly. This was a regression in v1.7.4.
18+
19+
- FreeRTOS:
20+
21+
- Add a built-in metric for tracking the FreeRTOS Timer Task stack bytes free,
22+
`timer_task_stack_free_bytes`. This metric is enabled by default and can be
23+
disabled by setting
24+
`#define MEMFAULT_FREERTOS_COLLECT_TIMER_STACK_FREE_BYTES 0` in
25+
`memfault_platform_config.h`.
26+
927
## [1.7.5] - 2024-03-29
1028

1129
### :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: 7127
2-
GIT COMMIT: 5997be4a28
3-
VERSION: 1.7.5
1+
BUILD ID: 7230
2+
GIT COMMIT: 28ff066c7d
3+
VERSION: 1.7.6

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 = 7, .patch = 5 }
23-
#define MEMFAULT_SDK_VERSION_STR "1.7.5"
22+
#define MEMFAULT_SDK_VERSION { .major = 1, .minor = 7, .patch = 6 }
23+
#define MEMFAULT_SDK_VERSION_STR "1.7.6"
2424

2525
#ifdef __cplusplus
2626
}

examples/esp32/apps/memfault_demo_app/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ void esp_heap_trace_alloc_hook(void *ptr, size_t size, uint32_t caps) {
380380
// This task started by cpu_start.c::start_cpu0_default().
381381
void app_main() {
382382
#if defined(CONFIG_MEMFAULT)
383-
#if defined(CONFIG_MEMFAULT_AUTOMATIC_INIT)
383+
#if !defined(CONFIG_MEMFAULT_AUTOMATIC_INIT)
384384
memfault_boot();
385385
#endif
386386
memfault_device_info_dump();
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Add application custom metrics
22
MEMFAULT_METRICS_KEY_DEFINE(Example_HeapFreeBytes, kMemfaultMetricType_Unsigned)
33
MEMFAULT_METRICS_KEY_DEFINE(Example_HeapMinFreeBytes, kMemfaultMetricType_Unsigned)
4-
MEMFAULT_METRICS_KEY_DEFINE(timer_task_stack_free_bytes, kMemfaultMetricType_Unsigned)
54

6-
#include "ports/freertos/config/memfault_metrics_heartbeat_freertos_task_runtime_config.def"
5+
#include "ports/freertos/config/memfault_metrics_heartbeat_freertos_config.def"

examples/freertos/src/metrics.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "FreeRTOS.h"
1010
#include "memfault/components.h"
11-
#include "timers.h"
1211

1312
#define EXAMPLE_TASK_STACKS 300
1413

@@ -37,21 +36,10 @@ void metrics_task_init(void) {
3736
&metrics_task_tcb);
3837
}
3938

40-
static void prv_record_timer_stack_free_bytes(void) {
41-
TaskHandle_t timer_task_handle = xTimerGetTimerDaemonTaskHandle();
42-
43-
UBaseType_t free_space = uxTaskGetStackHighWaterMark(timer_task_handle);
44-
45-
// uxTaskGetStackHighWaterMark() returns units of "words", so convert to bytes
46-
MEMFAULT_METRIC_SET_UNSIGNED(timer_task_stack_free_bytes, free_space * sizeof(StackType_t));
47-
}
48-
4939
void memfault_metrics_heartbeat_collect_sdk_data(void) {
5040
MEMFAULT_STATIC_ASSERT(
5141
MEMFAULT_METRICS_HEARTBEAT_INTERVAL_SECS <= (60 * 60),
5242
"Heartbeat must be an hour or less for runtime metrics to mitigate counter overflow");
5343

54-
prv_record_timer_stack_free_bytes();
55-
5644
memfault_freertos_port_task_runtime_metrics();
5745
}

ports/esp_idf/memfault/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,30 @@ component_compile_options(
219219
-DMEMFAULT_FREERTOS_REGISTRY_FULL_ERROR_LOG_INCLUDE="memfault_platform_freertos_error_log.h"
220220
)
221221

222+
# Extra compilation options set globally
223+
if (NOT DEFINED ENV{IDF_VERSION})
224+
set(IDF_VERSION "3.3.5")
225+
else()
226+
set(IDF_VERSION $ENV{IDF_VERSION})
227+
endif()
228+
if (IDF_VERSION VERSION_GREATER_EQUAL "5.0.0")
229+
# Empty for now, reserving for the future
230+
elseif (IDF_VERSION VERSION_GREATER_EQUAL "4.4.0")
231+
# ESP-IDF v4.4 forces the FreeRTOS config
232+
# INCLUDE_xTimerGetTimerDaemonTaskHandle=0, which is used to record timer task
233+
# stack in the SDK. Just disable the usage unconditionally.
234+
list(APPEND MEMFAULT_EXTRA_COMPILE_OPTIONS
235+
"-DMEMFAULT_FREERTOS_COLLECT_TIMER_STACK_FREE_BYTES=0"
236+
)
237+
else()
238+
# ESP-IDF < 4.4 don't force this setting, so set it ourselves to the correct
239+
# value.
240+
list(APPEND MEMFAULT_EXTRA_COMPILE_OPTIONS
241+
"-DINCLUDE_xTimerGetTimerDaemonTaskHandle=1"
242+
)
243+
endif()
244+
245+
222246
# Set the heartbeat config file to use the ESP-IDF port file, which will bring
223247
# in the user's heartbeat config automatically. Set it as a global compiler
224248
# option so it properly affects both component compilation and when the metric
@@ -232,6 +256,7 @@ if (IDF_VERSION_MAJOR VERSION_EQUAL 3)
232256
"-DMEMFAULT_METRICS_USER_HEARTBEAT_DEFS_FILE=\\\"memfault_esp_metrics_heartbeat_config.def\\\""
233257
"-DMEMFAULT_PLATFORM_CONFIG_FILE=\\\"memfault_esp_idf_port_config.h\\\""
234258
"-DMEMFAULT_TRACE_REASON_USER_DEFS_FILE=\\\"memfault_trace_reason_esp_idf_port_config.def\\\""
259+
${MEMFAULT_EXTRA_COMPILE_OPTIONS}
235260
)
236261
# convert from list to string before setting
237262
list(JOIN memfault_c_flags " " memfault_c_flags)
@@ -249,6 +274,7 @@ else()
249274
"-DMEMFAULT_METRICS_USER_HEARTBEAT_DEFS_FILE=\"memfault_esp_metrics_heartbeat_config.def\""
250275
"-DMEMFAULT_PLATFORM_CONFIG_FILE=\"memfault_esp_idf_port_config.h\""
251276
"-DMEMFAULT_TRACE_REASON_USER_DEFS_FILE=\"memfault_trace_reason_esp_idf_port_config.def\""
277+
${MEMFAULT_EXTRA_COMPILE_OPTIONS}
252278
)
253279
idf_build_set_property(
254280
COMPILE_OPTIONS

ports/esp_idf/memfault/config/memfault_esp_metrics_heartbeat_config.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#endif // CONFIG_MEMFAULT_LWIP_METRICS
99

1010
#if defined(CONFIG_MEMFAULT_FREERTOS_TASK_RUNTIME_STATS)
11-
#include "memfault_metrics_heartbeat_freertos_task_runtime_config.def"
11+
#include "memfault_metrics_heartbeat_freertos_config.def"
1212
#endif // CONFIG_MEMFAULT_FREERTOS_TASK_RUNTIME_STATS
1313

1414
#if defined(CONFIG_MEMFAULT_MBEDTLS_METRICS)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66
#elif MEMFAULT_FREERTOS_RUN_TIME_STATS_SINGLE_CORE
77
MEMFAULT_METRICS_KEY_DEFINE(idle_task_run_time_percent, kMemfaultMetricType_Unsigned)
88
#endif
9+
10+
#if MEMFAULT_FREERTOS_COLLECT_TIMER_STACK_FREE_BYTES
11+
MEMFAULT_METRICS_KEY_DEFINE(timer_task_stack_free_bytes, kMemfaultMetricType_Unsigned)
12+
#endif

ports/freertos/src/memfault_sdk_metrics_freertos.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
#ifdef MEMFAULT_USE_ESP32_FREERTOS_INCLUDE
1414
#include "freertos/FreeRTOS.h"
1515
#include "freertos/task.h"
16+
#include "freertos/timers.h"
1617
#include "memfault/esp_port/version.h"
1718
#else
1819
#include "FreeRTOS.h"
1920
#include "task.h"
21+
#include "timers.h"
2022
#endif
2123

2224
#if MEMFAULT_FREERTOS_COLLECT_RUN_TIME_STATS
@@ -97,6 +99,25 @@ static configRUN_TIME_COUNTER_TYPE prv_get_idle_counter_for_core(uint32_t core)
9799
}
98100
#endif
99101

102+
#if MEMFAULT_FREERTOS_COLLECT_TIMER_STACK_FREE_BYTES
103+
// FreeRTOS v9.0.0 made the xTimerGetTimerDaemonTaskHandle() API always
104+
// available:
105+
// https://github.com/FreeRTOS/FreeRTOS-Kernel/commit/6568ba6eb08a5ed0adf5141291d31f2144a79d08#diff-343560675a0f127a21d52dd3379ff23b01fe59fe87db61669efd3c903621fc22R427-R433
106+
#if (tskKERNEL_VERSION_MAJOR < 9) && (!INCLUDE_xTimerGetTimerDaemonTaskHandle)
107+
#error \
108+
"MEMFAULT_FREERTOS_COLLECT_TIMER_STACK_FREE_BYTES requires FreeRTOS v9.0.0 or later, or INCLUDE_xTimerGetTimerDaemonTaskHandle=1 in FreeRTOSConfig.h"
109+
#endif
110+
111+
static void prv_record_timer_stack_free_bytes(void) {
112+
TaskHandle_t timer_task_handle = xTimerGetTimerDaemonTaskHandle();
113+
114+
UBaseType_t free_space = uxTaskGetStackHighWaterMark(timer_task_handle);
115+
116+
// uxTaskGetStackHighWaterMark() returns units of "words", so convert to bytes
117+
MEMFAULT_METRIC_SET_UNSIGNED(timer_task_stack_free_bytes, free_space * sizeof(StackType_t));
118+
}
119+
#endif
120+
100121
void memfault_freertos_port_task_runtime_metrics(void) {
101122
#if MEMFAULT_FREERTOS_COLLECT_RUN_TIME_STATS
102123
static configRUN_TIME_COUNTER_TYPE s_prev_idle0_runtime = 0;
@@ -145,4 +166,8 @@ void memfault_freertos_port_task_runtime_metrics(void) {
145166
}
146167
#endif
147168
#endif // MEMFAULT_FREERTOS_COLLECT_RUN_TIME_STATS
169+
170+
#if MEMFAULT_FREERTOS_COLLECT_TIMER_STACK_FREE_BYTES
171+
prv_record_timer_stack_free_bytes();
172+
#endif
148173
}

0 commit comments

Comments
 (0)