Skip to content

Commit

Permalink
Memfault Firmware SDK 1.7.5 (Build 7127)
Browse files Browse the repository at this point in the history
  • Loading branch information
Memfault Inc committed Mar 29, 2024
1 parent f38cad1 commit 648e76f
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 8 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.7.5] - 2024-03-29

### :chart_with_upwards_trend: Improvements

- ESP-IDF:

- Modify a message when coredump storage is detected to be too small from an
error to a warning

- FreeRTOS:

- Fix an integer overflow issue affecting long heartbeat intervals (>> 1
hour), due to a limitation in the implementation of `pdMS_TO_TICKS()` in
older FreeRTOS versions. Newer version of FreeRTOS (as of `V11.0.0`
published December 2023) have fixed this
[issue](https://github.com/FreeRTOS/FreeRTOS-Kernel/commit/9c649ea7d1dd0206092697d73c894fd2c4fe29b3).
- Add a stack usage metric to the FreeRTOS example app

## [1.7.4] - 2024-03-26

### :chart_with_upwards_trend: Improvements
Expand Down
6 changes: 3 additions & 3 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
BUILD ID: 7065
GIT COMMIT: 3940f71502
VERSION: 1.7.4
BUILD ID: 7127
GIT COMMIT: 5997be4a28
VERSION: 1.7.5
4 changes: 2 additions & 2 deletions components/include/memfault/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ typedef struct {
uint8_t patch;
} sMfltSdkVersion;

#define MEMFAULT_SDK_VERSION { .major = 1, .minor = 7, .patch = 4 }
#define MEMFAULT_SDK_VERSION_STR "1.7.4"
#define MEMFAULT_SDK_VERSION { .major = 1, .minor = 7, .patch = 5 }
#define MEMFAULT_SDK_VERSION_STR "1.7.5"

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions components/panics/src/memfault_coredump_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ bool memfault_coredump_storage_check_size(void) {
return true;
}

MEMFAULT_LOG_ERROR("Coredump storage is %dB but need %dB", (int)storage_info.size,
(int)size_needed);
MEMFAULT_LOG_WARN("Coredump storage is %dB but need %dB", (int)storage_info.size,
(int)size_needed);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Add application custom metrics
MEMFAULT_METRICS_KEY_DEFINE(Example_HeapFreeBytes, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(Example_HeapMinFreeBytes, kMemfaultMetricType_Unsigned)
MEMFAULT_METRICS_KEY_DEFINE(timer_task_stack_free_bytes, kMemfaultMetricType_Unsigned)

#include "ports/freertos/config/memfault_metrics_heartbeat_freertos_task_runtime_config.def"
12 changes: 12 additions & 0 deletions examples/freertos/src/metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "FreeRTOS.h"
#include "memfault/components.h"
#include "timers.h"

#define EXAMPLE_TASK_STACKS 300

Expand Down Expand Up @@ -36,10 +37,21 @@ void metrics_task_init(void) {
&metrics_task_tcb);
}

static void prv_record_timer_stack_free_bytes(void) {
TaskHandle_t timer_task_handle = xTimerGetTimerDaemonTaskHandle();

UBaseType_t free_space = uxTaskGetStackHighWaterMark(timer_task_handle);

// uxTaskGetStackHighWaterMark() returns units of "words", so convert to bytes
MEMFAULT_METRIC_SET_UNSIGNED(timer_task_stack_free_bytes, free_space * sizeof(StackType_t));
}

void memfault_metrics_heartbeat_collect_sdk_data(void) {
MEMFAULT_STATIC_ASSERT(
MEMFAULT_METRICS_HEARTBEAT_INTERVAL_SECS <= (60 * 60),
"Heartbeat must be an hour or less for runtime metrics to mitigate counter overflow");

prv_record_timer_stack_free_bytes();

memfault_freertos_port_task_runtime_metrics();
}
17 changes: 16 additions & 1 deletion ports/freertos/src/memfault_metrics_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
#include "memfault/ports/freertos.h"
#include "timers.h"

// Define portTICK_PERIOD_MS is using an older version of FreeRTOS for compatibility
// portTICK_PERIOD_MS was added in FreeRTOS v8.0.0
#ifndef portTICK_PERIOD_MS
#define portTICK_PERIOD_MS portTICK_RATE_MS
#endif

#define SEC_TO_FREERTOS_TICKS(period_sec) \
((uint64_t)(((uint64_t)period_sec * 1000ULL) / (uint64_t)portTICK_PERIOD_MS))

static MemfaultPlatformTimerCallback *s_metric_timer_cb = NULL;
static void prv_metric_timer_callback(MEMFAULT_UNUSED TimerHandle_t handle) {
s_metric_timer_cb();
Expand All @@ -37,7 +46,13 @@ static TimerHandle_t prv_metric_timer_init(const char *const pcTimerName,

bool memfault_platform_metrics_timer_boot(uint32_t period_sec,
MemfaultPlatformTimerCallback callback) {
TimerHandle_t timer = prv_metric_timer_init("metric_timer", pdMS_TO_TICKS(period_sec * 1000),
// Validate MEMFAULT_METRICS_HEARTBEAT_INTERVAL_SECS does not overflow when converting to ticks
// Assumes a tick rate <= 1000 Hz and MEMFAULT_METRICS_HEARTBEAT_INTERVAL_SECS used as period
MEMFAULT_STATIC_ASSERT(
MEMFAULT_METRICS_HEARTBEAT_INTERVAL_SECS <= (uint32_t)(UINT32_MAX / 1000UL),
"Period too large and will cause overflow");

TimerHandle_t timer = prv_metric_timer_init("metric_timer", SEC_TO_FREERTOS_TICKS(period_sec),
pdTRUE, /* auto reload */
(void *)NULL, prv_metric_timer_callback);
if (timer == 0) {
Expand Down

0 comments on commit 648e76f

Please sign in to comment.