Skip to content

Commit 4ec7a0c

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 0.25.0 (Build 300504)
1 parent aa688ab commit 4ec7a0c

22 files changed

+240
-55
lines changed

CHANGES.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
### Changes between Memfault SDK 0.25.0 and SDK 0.24.2 - August 30, 2021
2+
3+
#### :chart_with_upwards_trend: Improvements
4+
5+
- Added a workaround to
6+
[`event_storage.h`](components/include/memfault/core/event_storage.h)
7+
to prevent compilation errors when using
8+
[the unity test framework](http://www.throwtheswitch.org/unity) to generate
9+
mocks.
10+
- Updated [`makefiles/MemfaultWorker.mk`](makefiles/MemfaultWorker.mk) to use
11+
`sort` to guarantee a deterministic file list order irrespestive of
12+
[make version](https://savannah.gnu.org/bugs/index.php?52076). A consistent
13+
order is useful for
14+
[reproducible builds](https://mflt.io/reproducible-builds).
15+
- Make use of `__has_include()` in Zephy port to remove the requirement of
16+
always needing to create`memfault_platform_config.h`,
17+
`memfault_metrics_heartbeat_config.def`, &
18+
`memfault_trace_reason_user_config.def` for a build to compile. To force a
19+
compile failure instead when any of these files do not exist, a user can set
20+
[`CONFIG_MEMFAULT_USER_CONFIG_SILENT_FAIL=n`](ports/zephyr/Kconfig)
21+
22+
#### :house: Internal
23+
24+
- The current version of the Memfault Firmware SDK can now be accessed
25+
programmatically from the
26+
[`memfault/version.h`](components/include/memfault/version.h).
27+
- Improved HTTP util parser when dealing with malformed status codes
28+
- Updated
29+
[nRF91 sample test app](examples/nrf-connect-sdk/nrf9160/memfault_demo_app) to
30+
be compatible with nRF Connect SDK 1.6
31+
132
### Changes between Memfault SDK 0.24.2 and SDK 0.24.1 - August 17, 2021
233

334
#### :chart_with_upwards_trend: Improvements

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
BUILD ID: 294635
2-
GIT COMMIT: 0276687c3
1+
BUILD ID: 300504
2+
GIT COMMIT: b6e67d617

components/core/src/memfault_build_id.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616

1717
#if MEMFAULT_USE_GNU_BUILD_ID
1818

19-
// Note: This variables is emitted by the linker script
19+
// Note: This variable is emitted by the linker script
2020
extern uint8_t __start_gnu_build_id_start[];
2121

2222
MEMFAULT_BUILD_ID_QUALIFIER sMemfaultBuildIdStorage g_memfault_build_id = {
2323
.type = kMemfaultBuildIdType_GnuBuildIdSha1,
2424
.len = sizeof(sMemfaultElfNoteSection),
2525
.short_len = MEMFAULT_EVENT_INCLUDED_BUILD_ID_SIZE_BYTES,
2626
.storage = __start_gnu_build_id_start,
27+
.sdk_version = MEMFAULT_SDK_VERSION,
2728
};
2829
#else
2930

@@ -35,5 +36,6 @@ MEMFAULT_BUILD_ID_QUALIFIER sMemfaultBuildIdStorage g_memfault_build_id = {
3536
.len = sizeof(g_memfault_sdk_derived_build_id),
3637
.short_len = MEMFAULT_EVENT_INCLUDED_BUILD_ID_SIZE_BYTES,
3738
.storage = g_memfault_sdk_derived_build_id,
39+
.sdk_version = MEMFAULT_SDK_VERSION,
3840
};
3941
#endif

components/core/src/memfault_build_id_private.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
//! Internal file that should never be included by a consumer of the SDK. See
1010
//! "memfault/core/build_info.h" for details on how to leverage the build id.
1111

12+
#include <stddef.h>
1213
#include <stdint.h>
1314

1415
#include "memfault/core/compiler.h"
16+
#include "memfault/version.h"
1517

1618
#ifdef __cplusplus
1719
extern "C" {
@@ -38,8 +40,13 @@ typedef struct {
3840
uint8_t short_len;
3941
uint8_t rsvd;
4042
const void *storage;
43+
const sMfltSdkVersion sdk_version;
4144
} sMemfaultBuildIdStorage;
4245

46+
MEMFAULT_STATIC_ASSERT(((offsetof(sMemfaultBuildIdStorage, type) == 0) &&
47+
(offsetof(sMemfaultBuildIdStorage, short_len) == 2)),
48+
"be sure to update fw_build_id.py!");
49+
4350
#if defined(MEMFAULT_UNITTEST)
4451
//! NB: For unit tests we want to be able to instrument the data in the test
4552
//! so we drop the `const` qualifier

components/core/src/memfault_data_packetizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ typedef MEMFAULT_PACKED_STRUCT {
126126

127127
static sMfltTransportState s_mflt_packetizer_state;
128128

129-
static eMfltDataSourceMask s_active_data_sources = kMfltDataSourceMask_All;
129+
static uint32_t s_active_data_sources = kMfltDataSourceMask_All;
130130

131131
void memfault_packetizer_set_active_sources(uint32_t mask) {
132132
memfault_packetizer_abort();

components/http/src/memfault_http_utils.c

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

99
#include "memfault/http/utils.h"
1010

11+
#include <limits.h>
1112
#include <stdio.h>
1213
#include <string.h>
1314

@@ -245,6 +246,18 @@ static int prv_str_to_dec(const char *buf, size_t buf_len, int *value_out) {
245246
}
246247

247248
int digit = c - '0';
249+
250+
// there's no limit to the size of a Content-Length value per specification:
251+
// https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2
252+
//
253+
// status code is required to be 3 digits per:
254+
// https://datatracker.ietf.org/doc/html/rfc7230#section-3.1.2
255+
//
256+
// any value that we can't fit in our variable is an error
257+
if ((INT_MAX / 10) < (result + digit)) {
258+
return -1; // result will overflow
259+
}
260+
248261
result = (result * 10) + digit;
249262
}
250263

components/include/memfault/core/data_packetizer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ typedef enum {
153153
//! @note This API can be used to prioritize the data source drained from the packetizer.
154154
//! This can be useful for use cases such as:
155155
//! - Devices with multi connectivity toplogies (i.e BLE & WiFi) For example, in this situation a
156-
//! user in this situation could choose to only enable Event and Log transfer when connected to
157-
//! BLE and enable all sources when connected to WiFi
158-
//! - Devices with extended periods where there is no connection to the internet In this
156+
//! user could choose to only enable Event and Log transfer when connected to BLE and enable all
157+
//! sources when connected to WiFi.
158+
//! - Devices with extended periods where there is no connection to the internet. In this
159159
//! situation, an end user may want to store data buffered in RAM (i.e events & logs) on flash
160160
//! to minimize the RAM footprint and prevent data from being lost by an unexpected reset.
161-
//! If an end user is already using a flash region to save coredumps, pre-encoded chunks
162-
//! can of just events can be saved, i.e
161+
//! If an end user is already saving coredumps in a dedicated flash region, pre-encoded chunks
162+
//! can of just events can be saved as follows:
163163
//!
164164
//! 1. Only enable draining of events with the following API call:
165165
//! memfault_packetizer_set_active_sources(kMfltDataSourceMask_Event);

components/include/memfault/core/event_storage.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
#include <stddef.h>
2323
#include <stdint.h>
2424

25+
// The unity test framework (http://www.throwtheswitch.org/unity) fails to generate mocks when
26+
// opaque pointers are used in a header. To work around, the problem, we pull in the full internal
27+
// definition for "sMemfaultEventStorageImpl" when the unity framework is being used.
28+
#if defined(UNITY_INCLUDE_CONFIG_H)
29+
#include "memfault/core/event_storage_implementation.h"
30+
#endif
31+
2532
#ifdef __cplusplus
2633
extern "C" {
2734
#endif

components/include/memfault/version.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
//! @file
44
//!
5+
//! Copyright (c) Memfault, Inc.
6+
//! See License.txt for details
7+
//!
58
//! Contains Memfault SDK version information.
69

710
#ifdef __cplusplus
@@ -11,12 +14,12 @@ extern "C" {
1114
#include <stdint.h>
1215

1316
typedef struct {
14-
uint16_t major;
15-
uint16_t minor;
16-
uint16_t patch;
17+
uint8_t major;
18+
uint8_t minor;
19+
uint8_t patch;
1720
} sMfltSdkVersion;
1821

19-
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 24, .patch = 2 }
22+
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 25, .patch = 0 }
2023

2124
#ifdef __cplusplus
2225
}

examples/nrf-connect-sdk/nrf9160/memfault_demo_app/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,33 @@ if(DEFINED ENV{MEMFAULT_INCLUDE_ZEPHYR_BOILERPLATE})
1212
include($ENV{ZEPHYR_BASE}/../nrf/cmake/boilerplate.cmake)
1313
endif()
1414

15+
# Starting in nRF Connect SDK >= 1.3, versions are exposed in
16+
# a CMake package:
17+
# https://github.com/nrfconnect/sdk-nrf/blob/master/share/ncs-package/cmake/NcsConfig.cmake
18+
#
19+
# We can pre-load the package before Zephyr to dynamically change Kconfig options based on version
20+
# which is not something that can be achieved with Zephyr today
21+
find_package(Ncs HINTS $ENV{ZEPHYR_BASE}/../nrf)
22+
23+
# Conditionally set Kconfig variables based on nRF Connect SDK version
24+
# (since setting non-existent variables result in a build time error which
25+
# would break compiling older builds)
26+
#
27+
# Zephyrs Kconfig extension pulls variables via the "CMake variable cache"
28+
# so we set the ones we need here using that:
29+
# https://docs.zephyrproject.org/latest/guides/build/kconfig/setting.html#the-initial-configuration
30+
if (NCS_VERSION_MAJOR)
31+
if (${NCS_VERSION_MAJOR} LESS_EQUAL 1 AND ${NCS_VERSION_MINOR} LESS 6 )
32+
# Required for logging to work from crash, deprecated in Zephyr included in NCS 1.6
33+
set(CONFIG_LOG_IMMEDIATE y CACHE INTERNAL "")
34+
elseif (${NCS_VERSION_MAJOR} LESS_EQUAL 1 AND ${NCS_VERSION_MINOR} GREATER_EQUAL 6 )
35+
set(CONFIG_MEMFAULT_NCS_PROVISION_CERTIFICATES n CACHE INTERNAL "")
36+
set(CONFIG_MEMFAULT_NCS_DEVICE_ID_RUNTIME y CACHE INTERNAL "")
37+
38+
set(CONFIG_NEWLIB_LIBC y CACHE INTERNAL "")
39+
endif()
40+
endif()
41+
1542
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
1643
project(hello_world)
1744

0 commit comments

Comments
 (0)