Skip to content

Commit f1a88a8

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.20.0 (Build 12555)
1 parent 03050f2 commit f1a88a8

File tree

61 files changed

+2872
-510
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2872
-510
lines changed

CHANGELOG.md

Lines changed: 152 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,152 @@ 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.20.0] - 2025-02-06
10+
11+
### 📈 Added
12+
13+
- General:
14+
15+
- Make `memfault_reboot_reason_get()` and
16+
`memfault_platform_metrics_timer_boot()` weakly defined in the
17+
[platform templates](ports/templates) to make removing them optional when
18+
first integrating
19+
20+
- Added a configuration option, `MEMFAULT_CRC16_BUILTIN`, that permits
21+
disabling the built-in [crc16](components/util/src/memfault_crc16_ccitt.c)
22+
implementation. The user should provide a compatible implementation of
23+
`memfault_crc16_compute()`. For example, if the Zephyr CRC library is used,
24+
a compatible implementation would be:
25+
26+
```c
27+
#include <zephyr/sys/crc.h>
28+
29+
uint16_t memfault_crc16_compute(uint16_t crc_initial_value, const void *data,
30+
size_t data_len_bytes) {
31+
return crc16_itu_t(crc_initial_value, data, data_len_bytes);
32+
}
33+
```
34+
35+
A Zephyr Kconfig setting, `CONFIG_MEMFAULT_CRC16_BUILTIN`, is also provided
36+
to control this option.
37+
38+
Thanks to [@JordanYates](https://github.com/JordanYates) for submitting this
39+
feature request in
40+
[#84](https://github.com/memfault/memfault-firmware-sdk/issues/84) !
41+
42+
- Added an example `daily_heartbeat` session to the
43+
[FreeRTOS QEMU example](examples/freertos/src/metrics.c), which demonstrates
44+
how to send a daily heartbeat session to Memfault. Daily Heartbeats are a
45+
special category of Session Metrics, and can be used to track device
46+
properties over a longer interval than heartbeat metrics.
47+
48+
- Added an optional field to the built-in
49+
[FreeRTOS task stack usage metrics](ports/include/memfault/ports/freertos/thread_metrics.h),
50+
`.get_task_handle`, which allows the user to provide a custom function to
51+
get the task handle for a given thread name, instead of using the thread
52+
name to identify the thread. This is useful in systems where there are
53+
threads with ambiguous names. The
54+
[ESP32 example app](examples/esp32/apps/memfault_demo_app/main/metrics.c) is
55+
updated to use this feature for ESP-IDF <5.3, where on dual-core SOCs, the
56+
per-core idle threads are both named `IDLE`.
57+
58+
- nRF Connect SDK:
59+
60+
- Added a new Kconfig symbol `CONFIG_MEMFAULT_FOTA_HTTP_FRAG_SIZE` to enable
61+
controlling the HTTP fragment size when using NCS >=2.9.9. Previously,
62+
`CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=y` was required, but this option
63+
was deprecated in NCS 2.9.9.
64+
65+
- Add built-in support for the `thermal_cpu_c` (CPU temperature) metric for
66+
nRF5x chips (nRF52 and nRF54 app core supported). Use the Kconfig setting
67+
`MEMFAULT_METRICS_CPU_TEMP` to disable the metric.
68+
69+
- Zephyr
70+
71+
- Add a new Kconfig setting, `CONFIG_MEMFAULT_HTTP_CLIENT_TIMEOUT_MS`, which
72+
controls the timeout for the Memfault HTTP client, used both for chunk
73+
upload and OTA operations. The default timeout is 5 seconds. Connections
74+
with poor latency may require a longer timeout to avoid premature
75+
disconnection. Thanks to [@chirambaht](https://github.com/chirambaht) for
76+
submitting this in
77+
[#86](https://github.com/memfault/memfault-firmware-sdk/issues/86)!
78+
79+
### 🐛 Fixed
80+
81+
- ESP-IDF:
82+
83+
- Use the configuration `MEMFAULT_LOG_MAX_LINE_SAVE_LEN` to set the max length
84+
of a log line when `CONFIG_MEMFAULT_LOG_USE_VPRINTF_HOOK=y`, which is the
85+
default setting in ESP-IDF. Previously, the log line was arbitrarily
86+
truncated in the Memfault vprintf hook before being saved to the Memfault
87+
log buffer.
88+
89+
- General:
90+
91+
- Remove the `MEMFAULT_PACKED` attribute for the `eMemfaultRebootReason`
92+
declaration; this compiler extension is not supported on IAR EWARM's
93+
compiler. Change the assembly shim to properly zero-extend the enum constant
94+
to avoid ABI issues when invoking the C fault handling code.
95+
96+
### 🛠️ Changed
97+
98+
- General:
99+
100+
- Remove an extra underscore in the folder name when using the
101+
[`eclipse_patch.py`](scripts/eclipse_patch.py) utility with a port name that
102+
is one folder deep (e.g. `freertos`)
103+
104+
- Rename the `memfault_crc16_ccitt_compute()` function to
105+
`memfault_crc16_compute()`. The CRC-16 algorithm used is canonically named
106+
`CRC-16/XMODEM`, **not** `CRC-16/CCITT` (aka `CRC-16/KERMIT`). The file
107+
implementing that function is left as `memfault_crc16_ccitt.c` for backwards
108+
compatibility. Thanks to [@JordanYates](https://github.com/JordanYates) for
109+
reporting this issue in
110+
[#83](https://github.com/memfault/memfault-firmware-sdk/issues/83)!
111+
112+
- Zephyr:
113+
114+
- Add a missing Kconfig dependency to `MEMFAULT_METRICS_THREADS`,
115+
`INIT_STACKS`. Also add missing dependencies to the Kconfig option
116+
`MEMFAULT_METRICS_DEFAULT_SET_ENABLE`:
117+
118+
- `INIT_STACKS`
119+
- `THREAD_RUNTIME_STATS`
120+
- `THREAD_STACK_INFO`
121+
122+
Thanks to [@JordanYates](https://github.com/JordanYates) for reporting this
123+
problem in
124+
[#86](https://github.com/memfault/memfault-firmware-sdk/issues/86) !
125+
126+
- Update the
127+
[memfault_zephyr_port_post_data()/memfault_zephyr_port_post_data_return_size()](ports/zephyr/common/memfault_platform_http.c)
128+
functions to only open the TLS socket if there is data ready to send, which
129+
is otherwise wasteful, as the socket will be closed without sending any
130+
Memfault data.
131+
132+
- Add an explicit module name, `memfault-firmware-sdk`, to the module
133+
manifest. This avoids issues when the SDK is registered in a Zephyr manifest
134+
under a directory name other than `memfault-firmware-sdk`. Thanks to
135+
[@JordanYates](https://github.com/JordanYates) for reporting this issue in
136+
[#81](https://github.com/memfault/memfault-firmware-sdk/issues/81)!
137+
138+
- Exclude unused stack space when capturing thread stacks, via the
139+
`thread.stack_info.delta` property. This reduces the amount of coredump
140+
storage used to capture thread stacks, especially when
141+
`CONFIG_STACK_POINTER_RANDOM` or `CONFIG_THREAD_LOCAL_STORAGE` is enabled.
142+
Thanks to [@JordanYates](https://github.com/JordanYates) for reporting this
143+
issue in [#81](https://github.com/memfault/memfault-firmware-sdk/issues/85)!
144+
145+
- nRF Connect SDK:
146+
147+
- Remove use of child and parent image functionality in the nRF9160 sample
148+
app, and replace with sysbuild support. Child image support was deprecated
149+
in NCS 2.7.0 in favor of sysbuild.
150+
151+
- Use the downloader library instead of the download client library when using
152+
NCS >= 2.9.9. The download_client was recently deprecated in favor of the
153+
downloader. Download client support is now in `memfault_fota_legacy.c`.
154+
9155
## [1.19.0] - 2025-01-10
10156

11157
### 📈 Added
@@ -2034,7 +2180,8 @@ earlier versions!
20342180
call the normal `z_fatal_error` handler at the end of Memfault fault
20352181
processing instead of rebooting the system. This is useful when user code
20362182
needs to run within `k_sys_fatal_error_handler()` just prior to system
2037-
shutdown. Thanks to @JordanYates for the patch! Fixes
2183+
shutdown. Thanks to [@JordanYates](https://github.com/JordanYates) for the
2184+
patch! Fixes
20382185
[#59](https://github.com/memfault/memfault-firmware-sdk/issues/59).
20392186
20402187
- Add a timeout to the initial `send()` socket operation in
@@ -2205,7 +2352,8 @@ earlier versions!
22052352
- Fix a 🐛 and warnings involving older Zephyr header paths. Resolves
22062353
[#62](https://github.com/memfault/memfault-firmware-sdk/issues/62) and
22072354
[#57](https://github.com/memfault/memfault-firmware-sdk/issues/57). Thanks
2208-
@JordanYates and @YHusain1 for reporting these issues.
2355+
[@JordanYates](https://github.com/JordanYates) and @YHusain1 for reporting
2356+
these issues.
22092357
22102358
### Changes between Memfault SDK 1.1.2 and 1.1.3 - Aug 8, 2023
22112359
@@ -2219,7 +2367,7 @@ earlier versions!
22192367
override the default. For Zephyr, the Kconfig option
22202368
`CONFIG_MEMFAULT_GNU_BUILD_ID_SOURCE_BUILTIN` can be used to override the
22212369
builtin section specifier + linker fragment for the GNU build ID. Thanks to
2222-
@JordanYates for posting this change in
2370+
[@JordanYates](https://github.com/JordanYates) for posting this change in
22232371
[#60](https://github.com/memfault/memfault-firmware-sdk/pull/60) 🎉
22242372
- Improvements to the ARMv7-R exception handling when the supervisor processor
22252373
mode is active
@@ -2245,7 +2393,7 @@ earlier versions!
22452393
- Zephyr:
22462394
- Fix a build error when `CONFIG_MEMFAULT_LOGGING=n`, see
22472395
[#56](https://github.com/memfault/memfault-firmware-sdk/issues/56). Thanks
2248-
to @JordanYates for reporting this issue!
2396+
to [@JordanYates](https://github.com/JordanYates) for reporting this issue!
22492397
- Fix a potential bug in the Memfault Log Backend when
22502398
`CONFIG_LOG_MODE_IMMEDIATE=y` when flushing of fault logs during a crash
22512399

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
BUILD ID: 12144
2-
GIT COMMIT: 24d5bb4ea2
3-
VERSION: 1.19.0
1+
BUILD ID: 12555
2+
GIT COMMIT: 7fcaa50c87
3+
VERSION: 1.20.0

components/core/src/memfault_log.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "memfault/core/sdk_assert.h"
2525
#include "memfault/util/base64.h"
2626
#include "memfault/util/circular_buffer.h"
27-
#include "memfault/util/crc16_ccitt.h"
27+
#include "memfault/util/crc16.h"
2828
#include "memfault_log_private.h"
2929

3030
#if MEMFAULT_LOG_DATA_SOURCE_ENABLED
@@ -63,9 +63,8 @@ static sMfltRamLogger s_memfault_ram_logger = {
6363
};
6464

6565
static uint16_t prv_compute_log_region_crc16(void) {
66-
return memfault_crc16_ccitt_compute(MEMFAULT_CRC16_CCITT_INITIAL_VALUE,
67-
&s_memfault_ram_logger.region_info,
68-
offsetof(sMfltLogStorageRegionInfo, crc16));
66+
return memfault_crc16_compute(MEMFAULT_CRC16_INITIAL_VALUE, &s_memfault_ram_logger.region_info,
67+
offsetof(sMfltLogStorageRegionInfo, crc16));
6968
}
7069

7170
uint32_t memfault_log_get_dropped_count(void) {

components/include/memfault/components.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
#include "memfault/util/base64.h"
6767
#include "memfault/util/cbor.h"
6868
#include "memfault/util/circular_buffer.h"
69-
#include "memfault/util/crc16_ccitt.h"
69+
#include "memfault/util/crc16.h"
7070
#include "memfault/util/rle.h"
7171
#include "memfault/util/varint.h"
7272
#include "memfault/version.h"

components/include/memfault/core/reboot_reason_types.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ extern "C" {
2424
#undef MEMFAULT_EXPECTED_REBOOT_REASON_DEFINE
2525
#undef MEMFAULT_UNEXPECTED_REBOOT_REASON_DEFINE
2626

27-
//! This enum must be packed to prevent compiler optimizations in instructions which load an
28-
//! eMemfaultRebootReason.
29-
typedef enum MEMFAULT_PACKED MfltResetReason {
27+
typedef enum MfltResetReason {
3028
// A reboot reason was not determined either by hardware or a previously marked reboot reason
3129
// This reason is classified as a crash when calculating the operational_crashfree_hours metric
3230
kMfltRebootReason_Unknown = 0x0000,
@@ -140,8 +138,6 @@ typedef enum MEMFAULT_PACKED MfltResetReason {
140138

141139
} eMemfaultRebootReason;
142140

143-
MEMFAULT_STATIC_ASSERT(sizeof(eMemfaultRebootReason) == 2, "Reboot reason enum must be 2 bytes");
144-
145141
#if MEMFAULT_REBOOT_REASON_CUSTOM_ENABLE == 1
146142
// Ensure that the custom reboot reasons are within the expected range
147143
#define MEMFAULT_EXPECTED_REBOOT_REASON_DEFINE(name) \

components/include/memfault/default_config.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,13 @@ extern "C" {
505505
// Util Configuration Options
506506
//
507507

508+
// Set this to 0 to disable the built-in CRC16 implementation. The platform will
509+
// need to provide a compatible implementation of memfault_crc16_compute(), as
510+
// defined in memfault/util/crc16.h.
511+
#ifndef MEMFAULT_CRC16_BUILTIN
512+
#define MEMFAULT_CRC16_BUILTIN 1
513+
#endif
514+
508515
// Enables the use of a (512 bytes) lookup table for CRC16 computation to improve performance
509516
//
510517
// For extremely constrained environments where a small amount of data is being sent anyway the

components/include/memfault/demo/cli.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ extern "C" {
2323
//! - 0: crash by MEMFAULT_ASSERT(0)
2424
//! - 1: crash by jumping to 0xbadcafe
2525
//! - 2: crash by unaligned memory store
26+
//! - 3: crash by MEMFAULT_ASSERT() deep in the callstack
27+
//! - 4: crash by MEMFAULT_SOFTWARE_WATCHDOG()
2628
int memfault_demo_cli_cmd_crash(int argc, char *argv[]);
2729

2830
#if MEMFAULT_COMPILER_ARM_CORTEX_M

components/include/memfault/util/crc16_ccitt.h renamed to components/include/memfault/util/crc16.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,30 @@
66
//! See LICENSE for details
77
//!
88
//! @brief
9-
//! C Implementation of the CRC-16 CCITT (xmodem) polynomial:
9+
//! C Implementation of the CRC-16/XMODEM polynomial:
1010
//! x^16 + x^12 + x^5 + 1 (0x1021)
1111
//! More details:
1212
//! http://reveng.sourceforge.net/crc-catalogue/16.htm#crc.cat.crc-16-xmodem
1313

1414
#include <stddef.h>
1515
#include <stdint.h>
1616

17-
#define MEMFAULT_CRC16_CCITT_INITIAL_VALUE 0x0
17+
#define MEMFAULT_CRC16_INITIAL_VALUE 0x0
1818

1919
#ifdef __cplusplus
2020
extern "C" {
2121
#endif
2222

23-
//! Computes the CRC16-CCITT value for the given sequence
23+
//! Computes the CRC-16/XMODEM value for the given sequence.
2424
//!
25-
//! The CRC is used in a wide spread of protocols (i.e HDLC, ISDN) and has a high probability of
26-
//! being able to detect errors when used like a checksum
27-
//!
28-
//! @param crc_initial_value Use MEMFAULT_CRC16_CCITT_INITIAL_VALUE when computing a new checksum
25+
//! @param crc_initial_value Use MEMFAULT_CRC16_INITIAL_VALUE when computing a new checksum
2926
//! over
3027
//! the entire data set passed in. Use the current CRC16-CCITT value if computing over a data set
3128
//! incrementally
3229
//! @param data The data to compute the crc over
3330
//! @param data_len_bytes the length of the data to compute the crc over, in bytes
34-
uint16_t memfault_crc16_ccitt_compute(uint16_t crc_initial_value, const void *data,
35-
size_t data_len_bytes);
31+
uint16_t memfault_crc16_compute(uint16_t crc_initial_value, const void *data,
32+
size_t data_len_bytes);
3633

3734
#ifdef __cplusplus
3835
}

components/include/memfault/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ typedef struct {
2020
} sMfltSdkVersion;
2121

2222
#define MEMFAULT_SDK_VERSION \
23-
{ .major = 1, .minor = 19, .patch = 0 }
24-
#define MEMFAULT_SDK_VERSION_STR "1.19.0"
23+
{ .major = 1, .minor = 20, .patch = 0 }
24+
#define MEMFAULT_SDK_VERSION_STR "1.20.0"
2525

2626
#ifdef __cplusplus
2727
}

components/panics/src/memfault_fault_handling_arm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ MEMFAULT_NAKED_FUNC void MEMFAULT_EXC_HANDLER_WATCHDOG(void) {
382382
"ldr r1, =%c0 \n" \
383383
"b memfault_fault_handler \n" \
384384
: \
385-
: "i"((uint16_t)_x))
385+
: "i"((uint32_t)_x))
386386
#else
387387
#define MEMFAULT_HARDFAULT_HANDLING_ASM(_x) \
388388
__asm volatile("mov r0, lr \n" \
@@ -403,7 +403,7 @@ MEMFAULT_NAKED_FUNC void MEMFAULT_EXC_HANDLER_WATCHDOG(void) {
403403
"ldr r1, =%c0 \n" \
404404
"b memfault_fault_handler \n" \
405405
: \
406-
: "i"((uint16_t)_x))
406+
: "i"((uint32_t)_x))
407407
#endif
408408

409409
MEMFAULT_NAKED_FUNC void MEMFAULT_EXC_HANDLER_HARD_FAULT(void) {

components/util/src/memfault_chunk_transport.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "memfault/core/compiler.h"
2525
#include "memfault/core/math.h"
2626
#include "memfault/util/chunk_transport.h"
27-
#include "memfault/util/crc16_ccitt.h"
27+
#include "memfault/util/crc16.h"
2828
#include "memfault/util/varint.h"
2929

3030
typedef struct {
@@ -134,7 +134,7 @@ bool memfault_chunk_transport_get_next_chunk(sMfltChunkTransportCtx *ctx, void *
134134
uint8_t *msg_bufp = &chunk_msg[chunk_msg_start_offset];
135135
ctx->read_msg(ctx->read_offset, msg_bufp, bytes_to_read);
136136
ctx->crc16_incremental =
137-
memfault_crc16_ccitt_compute(ctx->crc16_incremental, msg_bufp, bytes_to_read);
137+
memfault_crc16_compute(ctx->crc16_incremental, msg_bufp, bytes_to_read);
138138
chunk_msg_start_offset += bytes_to_read;
139139
}
140140

@@ -153,14 +153,17 @@ bool memfault_chunk_transport_get_next_chunk(sMfltChunkTransportCtx *ctx, void *
153153
if (buf_space_rem != 0) {
154154
// The encoded chunk consumes less space than the buffer provided. This can
155155
// happen when we reach the end of the underlying message being encoded
156+
// before exhausting the provided buffer.
156157
//
157-
// The Memfault backend allows for the last chunk in a message to exceed the
158-
// size of the underlying message being sent. This can be useful for topologies
159-
// that require sending chunks of a fixed size.
158+
// Note: ONLY for cases where the message spans multiple chunks, the final
159+
// chunk can be submitted to Memfault including the spare buffer space bytes
160+
// (i.e. using a fixed payload size to Memfault), and the Memfault backend
161+
// will discard the spare bytes. This is ONLY supported for multi-chunk
162+
// messages; single-chunk messages must be submitted with the exact payload
163+
// size as returned in *out_buf_len.
160164
//
161-
// Scrub the remaining part of the buffer for this situation with a know pattern
162-
// for debug purposes so it's easier to visually see the end of the chunk and to
163-
// prevent unintentional data from being sent.
165+
// Scrub the remaining part of the buffer for this situation with a known
166+
// pattern for debug purposes.
164167
memset(&chunk_msg[bytes_written], 0xBA, buf_space_rem);
165168
}
166169

0 commit comments

Comments
 (0)