Skip to content

Commit 648e76f

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.7.5 (Build 7127)
1 parent f38cad1 commit 648e76f

File tree

7 files changed

+54
-8
lines changed

7 files changed

+54
-8
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.5] - 2024-03-29
10+
11+
### :chart_with_upwards_trend: Improvements
12+
13+
- ESP-IDF:
14+
15+
- Modify a message when coredump storage is detected to be too small from an
16+
error to a warning
17+
18+
- FreeRTOS:
19+
20+
- Fix an integer overflow issue affecting long heartbeat intervals (>> 1
21+
hour), due to a limitation in the implementation of `pdMS_TO_TICKS()` in
22+
older FreeRTOS versions. Newer version of FreeRTOS (as of `V11.0.0`
23+
published December 2023) have fixed this
24+
[issue](https://github.com/FreeRTOS/FreeRTOS-Kernel/commit/9c649ea7d1dd0206092697d73c894fd2c4fe29b3).
25+
- Add a stack usage metric to the FreeRTOS example app
26+
927
## [1.7.4] - 2024-03-26
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: 7065
2-
GIT COMMIT: 3940f71502
3-
VERSION: 1.7.4
1+
BUILD ID: 7127
2+
GIT COMMIT: 5997be4a28
3+
VERSION: 1.7.5

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

2525
#ifdef __cplusplus
2626
}

components/panics/src/memfault_coredump_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ bool memfault_coredump_storage_check_size(void) {
1717
return true;
1818
}
1919

20-
MEMFAULT_LOG_ERROR("Coredump storage is %dB but need %dB", (int)storage_info.size,
21-
(int)size_needed);
20+
MEMFAULT_LOG_WARN("Coredump storage is %dB but need %dB", (int)storage_info.size,
21+
(int)size_needed);
2222
return false;
2323
}
2424

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
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)
45

56
#include "ports/freertos/config/memfault_metrics_heartbeat_freertos_task_runtime_config.def"

examples/freertos/src/metrics.c

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

99
#include "FreeRTOS.h"
1010
#include "memfault/components.h"
11+
#include "timers.h"
1112

1213
#define EXAMPLE_TASK_STACKS 300
1314

@@ -36,10 +37,21 @@ void metrics_task_init(void) {
3637
&metrics_task_tcb);
3738
}
3839

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+
3949
void memfault_metrics_heartbeat_collect_sdk_data(void) {
4050
MEMFAULT_STATIC_ASSERT(
4151
MEMFAULT_METRICS_HEARTBEAT_INTERVAL_SECS <= (60 * 60),
4252
"Heartbeat must be an hour or less for runtime metrics to mitigate counter overflow");
4353

54+
prv_record_timer_stack_free_bytes();
55+
4456
memfault_freertos_port_task_runtime_metrics();
4557
}

ports/freertos/src/memfault_metrics_freertos.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
#include "memfault/ports/freertos.h"
1717
#include "timers.h"
1818

19+
// Define portTICK_PERIOD_MS is using an older version of FreeRTOS for compatibility
20+
// portTICK_PERIOD_MS was added in FreeRTOS v8.0.0
21+
#ifndef portTICK_PERIOD_MS
22+
#define portTICK_PERIOD_MS portTICK_RATE_MS
23+
#endif
24+
25+
#define SEC_TO_FREERTOS_TICKS(period_sec) \
26+
((uint64_t)(((uint64_t)period_sec * 1000ULL) / (uint64_t)portTICK_PERIOD_MS))
27+
1928
static MemfaultPlatformTimerCallback *s_metric_timer_cb = NULL;
2029
static void prv_metric_timer_callback(MEMFAULT_UNUSED TimerHandle_t handle) {
2130
s_metric_timer_cb();
@@ -37,7 +46,13 @@ static TimerHandle_t prv_metric_timer_init(const char *const pcTimerName,
3746

3847
bool memfault_platform_metrics_timer_boot(uint32_t period_sec,
3948
MemfaultPlatformTimerCallback callback) {
40-
TimerHandle_t timer = prv_metric_timer_init("metric_timer", pdMS_TO_TICKS(period_sec * 1000),
49+
// Validate MEMFAULT_METRICS_HEARTBEAT_INTERVAL_SECS does not overflow when converting to ticks
50+
// Assumes a tick rate <= 1000 Hz and MEMFAULT_METRICS_HEARTBEAT_INTERVAL_SECS used as period
51+
MEMFAULT_STATIC_ASSERT(
52+
MEMFAULT_METRICS_HEARTBEAT_INTERVAL_SECS <= (uint32_t)(UINT32_MAX / 1000UL),
53+
"Period too large and will cause overflow");
54+
55+
TimerHandle_t timer = prv_metric_timer_init("metric_timer", SEC_TO_FREERTOS_TICKS(period_sec),
4156
pdTRUE, /* auto reload */
4257
(void *)NULL, prv_metric_timer_callback);
4358
if (timer == 0) {

0 commit comments

Comments
 (0)