Skip to content

Commit 66d6966

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.4.0 (Build 4099)
1 parent bfc5168 commit 66d6966

18 files changed

+247
-38
lines changed

CHANGES.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
# Memfault Firmware SDK Changelog
22

3+
## [1.4.0] - 2023-10-23
4+
5+
#### :rocket: New Features
6+
7+
- ESP-IDF:
8+
9+
- Implement support for a "zero-config" integration on ESP-IDF. This change
10+
makes the template + platform config files optional. See the
11+
[ESP32 Integration Guide](https://mflt.io/esp-tutorial) section on
12+
configuration files for details.
13+
14+
### :chart_with_upwards_trend: Improvements
15+
16+
- ESP-IDF:
17+
18+
- Fix a build issue when overriding the default device-info implementation,
19+
`CONFIG_MEMFAULT_DEFAULT_GET_DEVICE_INFO=n`. This was a regression in
20+
**1.3.3**.
21+
22+
- Add a new Kconfig flag, `MEMFAULT_COREDUMP_STORAGE_MAX_SIZE`, which can be
23+
used to set the Memfault SDK's built-in
24+
[ESP-IDF coredump storage implementation](sdk/embedded/ports/esp_idf/memfault/common/memfault_platform_coredump.c)
25+
to artificially limit the maximum coredump storage size. This is useful for
26+
situations where the default `memfault_platform_coredump_get_regions()`
27+
function is still desirable, but the coredump maximum size needs to be
28+
limited (eg for bandwidth reasons).
29+
30+
- Switch to using `ESP_DRAM_LOGE` when logging an error from Memfault's
31+
FreeRTOS task tracking when the number of tasks created on the system
32+
exceeds `MEMFAULT_PLATFORM_MAX_TRACKED_TASKS` (default of 16).
33+
34+
- General:
35+
36+
- Remove the setting of the Memfault Firmware SDK version into a string metric
37+
on system boot. This value is now automatically extracted by the Memfault
38+
backend from the symbol file, and does not need to be set by devices.
39+
340
## [1.3.5] - 2023-10-14
441

542
### :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: 3944
2-
GIT COMMIT: 429f30930
3-
VERSION: 1.3.5
1+
BUILD ID: 4099
2+
GIT COMMIT: bb1ba895f
3+
VERSION: 1.4.0

components/include/memfault/metrics/heartbeat_config.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
//! default health statistics for the fleet. All other metrics are provided by the user
33
//! of the sdk via the MEMFAULT_METRICS_USER_HEARTBEAT_DEFS_FILE file
44

5-
// Memfault SDK Version String
6-
#include "memfault/version.h"
7-
MEMFAULT_METRICS_STRING_KEY_DEFINE(MemfaultSdkMetric_sdk_version, sizeof(MEMFAULT_SDK_VERSION_STR) - 1)
85
// The time since the last heartbeat was collected in ms
96
MEMFAULT_METRICS_KEY_DEFINE(MemfaultSdkMetric_IntervalMs, kMemfaultMetricType_Timer)
107
// The number of reboots that have taken place since the last heartbeat was collected

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

2525
#ifdef __cplusplus
2626
}

components/metrics/src/memfault_metrics.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,9 +904,6 @@ int memfault_metrics_boot(const sMemfaultEventStorageImpl *storage_impl,
904904
return rv;
905905
}
906906

907-
rv = memfault_metrics_heartbeat_set_string(MEMFAULT_METRICS_KEY(MemfaultSdkMetric_sdk_version),
908-
MEMFAULT_SDK_VERSION_STR);
909-
910907
rv = prv_init_unexpected_reboot_metric();
911908
if (rv != 0) {
912909
return rv;

ports/esp_idf/memfault/CMakeLists.txt

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,50 @@ if (CONFIG_MEMFAULT_FREERTOS_TASK_RUNTIME_STATS)
188188
endif()
189189

190190
component_compile_options(-DMEMFAULT_ESP_HTTP_CLIENT_ENABLE=$ENV{MEMFAULT_ESP_HTTP_CLIENT_ENABLE})
191+
192+
# FreeRTOS error logging redirect for ESP-IDF compatibility.
193+
component_compile_options(
194+
-DMEMFAULT_FREERTOS_REGISTRY_FULL_ERROR_LOG_INCLUDE="memfault_platform_freertos_error_log.h"
195+
)
196+
191197
# Set the heartbeat config file to use the ESP-IDF port file, which will bring
192198
# in the user's heartbeat config automatically. Set it as a global compiler
193199
# option so it properly affects both component compilation and when the metric
194200
# keys are used in the application.
201+
#
202+
# Set the ESP-IDF specific Memfault platform config header as well.
195203
if (IDF_VERSION_MAJOR VERSION_EQUAL 3)
196204
# On pre-v4 of ESP-IDF, insert the compiler flag to the global CMAKE_C_FLAGS
197-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMEMFAULT_METRICS_USER_HEARTBEAT_DEFS_FILE=\\\"memfault_esp_metrics_heartbeat_config.def\\\"" CACHE STRING "Global C Flags" FORCE)
205+
set(
206+
memfault_c_flags
207+
"-DMEMFAULT_METRICS_USER_HEARTBEAT_DEFS_FILE=\\\"memfault_esp_metrics_heartbeat_config.def\\\""
208+
"-DMEMFAULT_PLATFORM_CONFIG_FILE=\\\"memfault_esp_idf_port_config.h\\\""
209+
"-DMEMFAULT_TRACE_REASON_USER_DEFS_FILE=\\\"memfault_trace_reason_esp_idf_port_config.def\\\""
210+
)
211+
# convert from list to string before setting
212+
list(JOIN memfault_c_flags " " memfault_c_flags)
213+
set(CMAKE_C_FLAGS
214+
"${CMAKE_C_FLAGS} ${memfault_c_flags}"
215+
CACHE STRING
216+
"Global C Flags"
217+
FORCE
218+
)
198219
else()
199-
idf_build_set_property(COMPILE_OPTIONS -DMEMFAULT_METRICS_USER_HEARTBEAT_DEFS_FILE="memfault_esp_metrics_heartbeat_config.def" APPEND)
220+
# set these as compile_options, not compile_definitions; pre-v5 of ESP-IDF
221+
# required the -D prefix, post-v5 auto strips it, but for safety, set them as
222+
# plain options not "definitions"
223+
list(APPEND compile_options
224+
"-DMEMFAULT_METRICS_USER_HEARTBEAT_DEFS_FILE=\"memfault_esp_metrics_heartbeat_config.def\""
225+
"-DMEMFAULT_PLATFORM_CONFIG_FILE=\"memfault_esp_idf_port_config.h\""
226+
"-DMEMFAULT_TRACE_REASON_USER_DEFS_FILE=\"memfault_trace_reason_esp_idf_port_config.def\""
227+
)
228+
idf_build_set_property(
229+
COMPILE_OPTIONS
230+
"${compile_options}"
231+
APPEND
232+
)
233+
# idf_build_get_property(bleh COMPILE_OPTIONS)
234+
# message(FATAL_ERROR "COMPILE_OPTIONS=${bleh}")
200235
endif()
201236

202237
# We will intercept the panic handlers enabled by CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH

ports/esp_idf/memfault/Kconfig

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ menu "Memfault"
3232
been shipped and the partition table cannot be modified, an
3333
OTA slot can be used instead.
3434

35+
config MEMFAULT_COREDUMP_STORAGE_MAX_SIZE
36+
int "The maximum size of a coredump (0=partition max size)"
37+
default 0
38+
help
39+
The maximum size of a coredump. If a coredump is larger than this
40+
size, it will be truncated to this size. Must be aligned to
41+
SPI_FLASH_SEC_SIZE. When set to =0 (the default), Memfault will
42+
attempt to capture the entire RAM region of the device, up to the
43+
maximum size of the `coredump` region. If it's desirable to
44+
artificially reduce the utilized space in the `coredump` partition,
45+
setting a non-zero value will cause the Memfault ESP-IDF port's
46+
'memfault_platform_coredump_storage_get_info()' function to return
47+
the threshold value set here as the size of the partition..
48+
3549
config MEMFAULT_AUTOMATIC_INIT
3650
bool "[DEPRECATED] Automatically initialize the SDK when the system is booted"
3751
default n
@@ -40,29 +54,47 @@ menu "Memfault"
4054
`memfault_boot`. This option is deprecated and not supported.
4155
A build error will be generated when enabling this option.
4256

43-
menuconfig MEMFAULT_DEFAULT_GET_DEVICE_INFO
57+
menu "Builtin device info implementation"
58+
59+
config MEMFAULT_DEFAULT_GET_DEVICE_INFO
4460
bool "Enables the default memfault_platform_get_device_info() implementation"
4561
default y
4662
help
4763
Enable a default implementation of
4864
memfault_platform_get_device_info(). Disable this config to
4965
implement a custom version of the function.
5066

51-
if MEMFAULT_DEFAULT_GET_DEVICE_INFO
52-
5367
config MEMFAULT_DEVICE_INFO_HARDWARE_VERSION
54-
string "Hardware version used in the default device info implementation"
68+
string "Hardware version used in memfault_esp_port_get_device_info()"
5569
default "$(IDF_TARGET)-proto"
5670

5771
config MEMFAULT_DEVICE_INFO_SOFTWARE_VERSION
58-
string "Software version used in the default device info implementation"
72+
string "Software version used in memfault_esp_port_get_device_info()"
5973
default "1.0.0-dev"
6074

6175
config MEMFAULT_DEVICE_INFO_SOFTWARE_TYPE
62-
string "Software type used in the default device info implementation"
76+
string "Software type used in memfault_esp_port_get_device_info()"
6377
default "esp32-main"
6478

65-
endif # MEMFAULT_DEFAULT_GET_DEVICE_INFO
79+
endmenu # Builtin device info implementation
80+
81+
config MEMFAULT_PLATFORM_CONFIG_FILE
82+
string "Name of the Memfault platform config file"
83+
default "memfault_platform_config.h"
84+
help
85+
The name of the file which contains the Memfault platform config
86+
options. This file must be included in the project's include path.
87+
88+
config MEMFAULT_USER_CONFIG_SILENT_FAIL
89+
bool "Continue with build even if user configuration of Memfault SDK is missing"
90+
default y
91+
help
92+
When enabled, __has_include is used to conditionally include the three Memfault
93+
configuration files to a port if they exist instead of failing to compile if
94+
they do not:
95+
memfault_platform_config.h
96+
memfault_metrics_heartbeat_config.def
97+
memfault_trace_reason_user_config.def
6698

6799
config MEMFAULT_HTTP_CLIENT_TIMEOUT_MS
68100
int "The HTTP client timeout in milliseconds"

ports/esp_idf/memfault/common/memfault_platform_coredump.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,26 @@ void memfault_platform_coredump_storage_get_info(sMfltCoredumpStorageInfo *info)
298298
// sanity check that the memory holding the info is populated and not corrupted
299299
const esp_partition_t *core_part = prv_validate_and_get_core_partition();
300300
if (core_part == NULL) {
301-
*info = (sMfltCoredumpStorageInfo) { 0 };
301+
*info = (sMfltCoredumpStorageInfo){0};
302302
return;
303303
}
304304

305-
*info = (sMfltCoredumpStorageInfo) {
306-
.size = core_part->size,
305+
#if defined(CONFIG_MEMFAULT_COREDUMP_STORAGE_LIMIT_SIZE)
306+
// confirm MAX_SIZE is aligned to SPI_FLASH_SEC_SIZE
307+
MEMFAULT_STATIC_ASSERT(
308+
(CONFIG_MEMFAULT_COREDUMP_STORAGE_MAX_SIZE % SPI_FLASH_SEC_SIZE == 0),
309+
"Error, check CONFIG_MEMFAULT_COREDUMP_STORAGE_MAX_SIZE value: " MEMFAULT_EXPAND_AND_QUOTE(
310+
CONFIG_MEMFAULT_COREDUMP_STORAGE_MAX_SIZE));
311+
#endif
312+
313+
*info = (sMfltCoredumpStorageInfo) {
314+
.size =
315+
#if CONFIG_MEMFAULT_COREDUMP_STORAGE_MAX_SIZE > 0
316+
MEMFAULT_MIN(core_part->size, CONFIG_MEMFAULT_COREDUMP_STORAGE_MAX_SIZE)
317+
#else
318+
core_part->size
319+
#endif
320+
,
307321
.sector_size = SPI_FLASH_SEC_SIZE,
308322
};
309323
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#pragma once
2+
3+
//! @file
4+
//!
5+
//! Copyright (c) Memfault, Inc.
6+
//! See License.txt for details
7+
//
8+
// ESP-IDF specific Memfault configs. This file has the following purposes:
9+
// 1. provide a way to set Memfault configs (default_config.h overrides) from
10+
// ESP-IDF Kconfig flags
11+
// 2. remove the requirement for a user to provide "memfault_platform_config.h"
12+
// themselves, if they don't need to override any default options
13+
14+
#ifdef __cplusplus
15+
extern "C" {
16+
#endif
17+
18+
#include "sdkconfig.h"
19+
20+
// Pick up any user configuration overrides
21+
#if CONFIG_MEMFAULT_USER_CONFIG_SILENT_FAIL
22+
23+
#if __has_include(CONFIG_MEMFAULT_PLATFORM_CONFIG_FILE)
24+
#include CONFIG_MEMFAULT_PLATFORM_CONFIG_FILE
25+
#endif
26+
27+
#else
28+
29+
#include CONFIG_MEMFAULT_PLATFORM_CONFIG_FILE
30+
31+
#endif /* CONFIG_MEMFAULT_USER_CONFIG_SILENT_FAIL */
32+
33+
#ifdef __cplusplus
34+
}
35+
#endif

ports/esp_idf/memfault/config/memfault_esp_metrics_heartbeat_config.def

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// Required to pull in Kconfig-generated definitions
44
#include "sdkconfig.h"
55

6-
76
#if CONFIG_MEMFAULT_LWIP_METRICS
87
#include "memfault_lwip_metrics_heartbeat_config.def"
98
#endif // CONFIG_MEMFAULT_LWIP_METRICS
@@ -24,5 +23,14 @@ MEMFAULT_METRICS_KEY_DEFINE(wifi_connected_time_ms, kMemfaultMetricType_Timer)
2423
MEMFAULT_METRICS_KEY_DEFINE(wifi_disconnect_count, kMemfaultMetricType_Unsigned)
2524
#endif // CONFIG_MEMFAULT_ESP_WIFI_METRICS
2625

27-
// Include user metrics
26+
#if CONFIG_MEMFAULT_USER_CONFIG_SILENT_FAIL
27+
28+
# if __has_include("memfault_metrics_heartbeat_config.def")
29+
# include "memfault_metrics_heartbeat_config.def"
30+
# endif
31+
32+
#else
33+
2834
#include "memfault_metrics_heartbeat_config.def"
35+
36+
#endif /* CONFIG_MEMFAULT_USER_CONFIG_SILENT_FAIL */

0 commit comments

Comments
 (0)