Skip to content

Commit c59f03f

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 0.33.1 (Build 503780)
1 parent 969baaf commit c59f03f

File tree

76 files changed

+563
-334
lines changed

Some content is hidden

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

76 files changed

+563
-334
lines changed

CHANGES.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
### Changes between Memfault SDK 0.33.0 and SDK 0.33.1 - Aug 26, 2022
2+
3+
#### :chart_with_upwards_trend: Improvements
4+
5+
- Fix a :bug: in the heap stats component (#32), thanks @christophgreen for
6+
reporting it!
7+
- Zephyr port updates:
8+
- add support for the newly namespaced Zephyr include path in upcoming Zephyr
9+
v3.2 (`#include <zephyr.h>``#include <zephyr/zephyr.h>`). The includes
10+
were moved
11+
[prior to v3.1](https://github.com/zephyrproject-rtos/zephyr/commit/53ef68d4598b2f9005c5da3fc0b860ca1999d350)
12+
of Zephyr, but v3.2
13+
[changes the backwards compatibility support to opt-in](https://github.com/zephyrproject-rtos/zephyr/commit/1ec0c6f5308937dc8e77acc2567d6f53cdd7a74e).
14+
The Memfault SDK is now updated to support both.
15+
- fix Zephyr Memfault log capture to have the correct prefix in the decoded
16+
output when using LOG2 - previously all log lines regardless of level would
17+
have an `E` prefix (regression introduced in Memfault SDK version 0.32.0)
18+
- fix Zephyr Memfault log capture when in `CONFIG_LOG_MODE_IMMEDIATE` and
19+
using LOG2 to capture the full log line instead of each logged character as
20+
a separate line.
21+
22+
#### :house: Internal
23+
24+
- Zephyr port folder for `v2.x` migrated to `common`, now that Zephyr v1.14
25+
support has been removed (done in v0.32.0 of the Memfault SDK)
26+
- Update README's for the example projects to match the new demo shell command
27+
structure (`crash 1``test_hardfault`, etc).
28+
- Tidy up nrf9160 example app Kconfig setup
29+
- Fix parallel unit test invocation
30+
131
### Changes between Memfault SDK 0.33.0 and SDK 0.32.2 - Aug 18, 2022
232

333
#### :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: 497178
2-
GIT COMMIT: 3f51dc76a
1+
BUILD ID: 503780
2+
GIT COMMIT: ef36b85f7

components/core/src/memfault_heap_stats.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void memfault_heap_stats_free(const void *ptr) {
9393

9494
// if the pointer exists in the tracked stats, mark it as freed
9595
for (size_t i = 0; i < MEMFAULT_ARRAY_SIZE(g_memfault_heap_stats_pool); i++) {
96-
if (g_memfault_heap_stats_pool[i].ptr == ptr) {
96+
if ((g_memfault_heap_stats_pool[i].ptr == ptr) && g_memfault_heap_stats_pool[i].info.in_use) {
9797
g_memfault_heap_stats_pool[i].info.in_use = 0;
9898
break;
9999
}

components/demo/src/memfault_demo_shell.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ static bool prv_should_ignore_eol_char(char c) {
145145
}
146146

147147
//
148-
// First end of line character detected. We will use this character as our EOL delimiter and
149-
// ignore the opposite character when we see it in the future.
148+
// Check to see if we have encountered our first newline character since the shell was booted
149+
// (either a CR ('\r') or LF ('\n')). Once found, we will use this character as our EOL delimiter
150+
// and ignore the opposite character if we see it in the future.
150151
//
151152

152153
if (c == '\r') {

components/include/memfault/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef struct {
1919
uint8_t patch;
2020
} sMfltSdkVersion;
2121

22-
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 33, .patch = 0 }
22+
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 33, .patch = 1 }
2323

2424
#ifdef __cplusplus
2525
}

examples/mbed/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ is used as serial number. You can change this to match your requirements (see
122122

123123
### Causing a crash
124124

125-
Command `crash 1` will trigger a hard fault due to a bad instruction fetch at a
125+
Command `test_hardfault` will trigger a hard fault due to a bad instruction fetch at a
126126
non-existing address, `0xbadcafe`.
127127

128128
```
129-
mflt> crash 1
129+
mflt> test_hardfault
130130
... etc ...
131131
```
132132

examples/nrf-connect-sdk/nrf5/README.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,44 @@ The console has several Memfault test commands available:
3434

3535
```bash
3636
uart:~$ mflt help
37-
mflt - Memfault Test Commands
3837
Subcommands:
39-
reboot :trigger a reboot and record it using memfault
40-
get_core :gets the core
41-
clear_core :clear the core
42-
crash :trigger a crash
43-
test_log :Writes test logs to log buffer
44-
trigger_logs :Trigger capture of current log buffer contents
45-
hang :trigger a hang to test watchdog functionality
38+
clear_core :clear coredump collected
4639
export :dump chunks collected by Memfault SDK using
4740
https://mflt.io/chunk-data-export
48-
trace :Capture an example trace event
41+
get_core :check if coredump is stored and present
4942
get_device_info :display device information
43+
get_latest_release :checks to see if new ota payload is available
44+
post_chunks :Post Memfault data to cloud
45+
test :commands to verify memfault data collection
46+
(https://mflt.io/mcu-test-commands)
5047
post_chunks :Post Memfault data to cloud
51-
trigger_heartbeat :Trigger an immediate capture of all heartbeat metrics
5248
get_latest_release :checks to see if new ota payload is available
5349
```
5450
51+
The `mflt test` subgroup contains commands for testing Memfault functionality:
52+
53+
```bash
54+
uart:~$ mflt test help
55+
test - commands to verify memfault data collection
56+
(https://mflt.io/mcu-test-commands)
57+
Subcommands:
58+
assert :trigger memfault assert
59+
busfault :trigger a busfault
60+
hang :trigger a hang
61+
hardfault :trigger a hardfault
62+
memmanage :trigger a memory management fault
63+
usagefault :trigger a usage fault
64+
zassert :trigger a zephyr assert
65+
reboot :trigger a reboot and record it using memfault
66+
heartbeat :trigger an immediate capture of all heartbeat metrics
67+
log_capture :trigger capture of current log buffer contents
68+
logs :writes test logs to log buffer
69+
trace :capture an example trace event
70+
```
71+
5572
For example, to test the coredump functionality:
5673
57-
1. run `mflt crash` and wait for the board to reset
74+
1. run `mflt test hardfault` and wait for the board to reset
5875
2. run `mflt get_core` to confirm the coredump was saved
5976
3. run `mflt export` to print out the base-64 chunks:
6077

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

Lines changed: 73 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ if(DEFINED ENV{MEMFAULT_ZEPHYR_EXTRA_MODULE_INCLUDE})
66
list(APPEND ZEPHYR_EXTRA_MODULES $ENV{ZEPHYR_BASE}/../modules/memfault-firmware-sdk/ports)
77
endif()
88

9-
# Required for app to compile against nRF Connect SDK <= v1.2
10-
if(DEFINED ENV{MEMFAULT_INCLUDE_ZEPHYR_BOILERPLATE})
11-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
12-
include($ENV{ZEPHYR_BASE}/../nrf/cmake/boilerplate.cmake)
13-
endif()
14-
159
# Starting in nRF Connect SDK >= 1.3, versions are exposed in
1610
# a CMake package:
1711
# https://github.com/nrfconnect/sdk-nrf/blob/master/share/ncs-package/cmake/NcsConfig.cmake
@@ -20,65 +14,93 @@ endif()
2014
# which is not something that can be achieved with Zephyr today
2115
find_package(Ncs HINTS $ENV{ZEPHYR_BASE}/../nrf)
2216

23-
# Conditionally set Kconfig variables based on nRF Connect SDK version
17+
if (NOT NCS_VERSION_MAJOR)
18+
# Note: If we cannot resolve the NCS version, assume we are using 1.2.x which is the oldest
19+
# version Memfault has been tested against
20+
set(NCS_VERSION_MAJOR 1)
21+
set(NCS_VERSION_MINOR 2)
22+
set(NCS_VERSION_PATCH 0)
23+
endif()
24+
25+
# Below we conditionally set Kconfig variables based on nRF Connect SDK version
2426
# (since setting non-existent variables result in a build time error which
2527
# would break compiling older builds)
2628
#
2729
# Zephyrs Kconfig extension pulls variables via the "CMake variable cache"
2830
# 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 5 )
32-
# Legacy name for CONFIG_DEBUG_THREAD_INFO needed for nRF Connect version <= 1.5
33-
# due to the version of Zephyr included (pre v2.5)
34-
set(CONFIG_OPENOCD_SUPPORT n CACHE INTERNAL "")
35-
elseif (${NCS_VERSION_MAJOR} LESS_EQUAL 1 AND ${NCS_VERSION_MINOR} LESS 6 )
36-
# Required for logging to work from crash, deprecated in Zephyr included in NCS 1.6
37-
set(CONFIG_LOG_IMMEDIATE y CACHE INTERNAL "")
38-
elseif (${NCS_VERSION_MAJOR} LESS_EQUAL 1 AND ${NCS_VERSION_MINOR} GREATER_EQUAL 6 )
39-
set(CONFIG_MEMFAULT_NCS_PROVISION_CERTIFICATES n CACHE INTERNAL "")
40-
set(CONFIG_MEMFAULT_NCS_DEVICE_ID_RUNTIME y CACHE INTERNAL "")
41-
42-
set(CONFIG_NEWLIB_LIBC y CACHE INTERNAL "")
43-
endif()
31+
# https://docs.zephyrproject.org/latest/build/kconfig/setting.html#the-initial-configuration
32+
33+
if (${NCS_VERSION_MAJOR}.${NCS_VERSION_MINOR}.${NCS_VERSION_PATCH} VERSION_LESS 1.3)
34+
else() # nRF Connect SDK Version >= 1.3.0
35+
# We cannot set for NCS <= 1.2 because on older versions of zephyr the argument was not
36+
# directly user-configurable (no prompt in Kconfig)
37+
set(CONFIG_SHELL_LOG_BACKEND n CACHE INTERNAL "")
38+
endif()
4439

40+
if (${NCS_VERSION_MAJOR}.${NCS_VERSION_MINOR}.${NCS_VERSION_PATCH} VERSION_LESS 1.5)
41+
# Legacy name for CONFIG_DEBUG_THREAD_INFO needed for nRF Connect version <= 1.5
42+
# due to the version of Zephyr included (pre v2.5)
43+
set(CONFIG_OPENOCD_SUPPORT y CACHE INTERNAL "")
44+
else() # nRF Connect SDK Version >= 1.5.0
4545
# Enable Memfault FOTA Support
4646
#
47-
# We enable conditionally because prior to NCS < 1.4 a small patch (https://mflt.io/nrf-fota) was
47+
# We enable conditionally because prior to NCS < 1.5 a small patch (https://mflt.io/nrf-fota) was
4848
# needed in order for things to work
49-
if (${NCS_VERSION_MAJOR}.${NCS_VERSION_MINOR}.${NCS_VERSION_PATCH} GREATER_EQUAL 1.5.0)
50-
set(CONFIG_MEMFAULT_FOTA y CACHE INTERNAL "")
51-
set(CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE 400 CACHE INTERNAL "")
52-
set(CONFIG_DOWNLOAD_CLIENT_STACK_SIZE 1600 CACHE INTERNAL "")
53-
54-
# Note: Can optionally be changed to =y to implement
55-
# a custom event handler for FOTA events
56-
# CONFIG_MEMFAULT_FOTA_DOWNLOAD_CALLBACK_CUSTOM=n
49+
set(CONFIG_MEMFAULT_FOTA y CACHE INTERNAL "")
50+
set(CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE 400 CACHE INTERNAL "")
51+
set(CONFIG_DOWNLOAD_CLIENT_STACK_SIZE 1600 CACHE INTERNAL "")
52+
53+
# Note: Can optionally be changed to =y to implement
54+
# a custom event handler for FOTA events
55+
# CONFIG_MEMFAULT_FOTA_DOWNLOAD_CALLBACK_CUSTOM=n
56+
endif()
57+
58+
59+
if (${NCS_VERSION_MAJOR}.${NCS_VERSION_MINOR}.${NCS_VERSION_PATCH} VERSION_LESS 1.6.0)
60+
# Required for logging to work from crash but deprecated in Zephyr included in NCS 1.6
61+
set(CONFIG_LOG_IMMEDIATE y CACHE INTERNAL "")
62+
63+
# NCS 1.6 was the first one which introduced setting the project key via
64+
# Kconfig. Look for this argument and remap to a regular compiler definition
65+
# that gets picked up in memfault_demo_app/src/main.c
66+
if (CONFIG_MEMFAULT_NCS_PROJECT_KEY)
67+
add_compile_definitions(MEMFAULT_NCS_PROJECT_KEY=${CONFIG_MEMFAULT_NCS_PROJECT_KEY})
68+
unset(CONFIG_MEMFAULT_NCS_PROJECT_KEY CACHE)
5769
endif()
70+
else() # nRF Connect SDK Version >= 1.6.0
71+
set(CONFIG_MEMFAULT_NCS_PROVISION_CERTIFICATES n CACHE INTERNAL "")
72+
set(CONFIG_MEMFAULT_NCS_DEVICE_ID_RUNTIME y CACHE INTERNAL "")
73+
set(CONFIG_NEWLIB_LIBC y CACHE INTERNAL "")
74+
endif()
5875

76+
if (${NCS_VERSION_MAJOR}.${NCS_VERSION_MINOR}.${NCS_VERSION_PATCH} VERSION_LESS 1.7.99)
5977
# These were removed in NCS 1.8.0, but are needed prior to that. Enable them
6078
# if NCS version <1.7.99 (.99 patch version is used for the next revision's
6179
# development series)
62-
if (${NCS_VERSION_MAJOR}.${NCS_VERSION_MINOR}.${NCS_VERSION_PATCH} VERSION_LESS 1.7.99)
63-
set(CONFIG_BSD_LIBRARY y CACHE INTERNAL "")
64-
set(CONFIG_BSD_LIBRARY_SYS_INIT n CACHE INTERNAL "")
65-
# ^ Note: CONFIG_BSD_ were renamed to _NRF_MODEM_ in
66-
# nRF Connect SDK v1.5. We use the legacy names for now
67-
# so this app can continue to compile on older targets
68-
#
69-
# CONFIG_NRF_MODEM_LIB
70-
# CONFIG_NRF_MODEM_LIB_SYS_INIT
71-
72-
# For nRF Connect SDK v1.5 default value changed here
73-
set(CONFIG_AT_CMD_SYS_INIT n CACHE INTERNAL "")
74-
else() # nRF Connect SDK Version >= 1.8.0
75-
# in v1.8+, use the modem_info library to get the IMEI for device_serial
76-
set(CONFIG_MEMFAULT_NCS_DEVICE_ID_RUNTIME y CACHE INTERNAL "")
77-
set(CONFIG_MODEM_INFO y CACHE INTERNAL "")
78-
79-
# Use SPM instead of TFM for Secure Firmware as TFM does not (yet) support forwarding of fault handlers
80-
set(CONFIG_BUILD_WITH_TFM n CACHE INTERNAL "")
81-
endif()
80+
set(CONFIG_BSD_LIBRARY y CACHE INTERNAL "")
81+
set(CONFIG_BSD_LIBRARY_SYS_INIT n CACHE INTERNAL "")
82+
# ^ Note: CONFIG_BSD_ were renamed to _NRF_MODEM_ in
83+
# nRF Connect SDK v1.5. We use the legacy names here
84+
# so the app can continue to compile on older targets
85+
#
86+
# CONFIG_NRF_MODEM_LIB
87+
# CONFIG_NRF_MODEM_LIB_SYS_INIT
88+
89+
# For nRF Connect SDK v1.5 default value changed here
90+
set(CONFIG_AT_CMD_SYS_INIT n CACHE INTERNAL "")
91+
else() # nRF Connect SDK Version >= 1.8.0
92+
# in v1.8+, use the modem_info library to get the IMEI for device_serial
93+
set(CONFIG_MODEM_INFO y CACHE INTERNAL "")
94+
95+
# Use SPM instead of TFM for Secure Firmware as TFM does not (yet) support forwarding of fault handlers
96+
set(CONFIG_BUILD_WITH_TFM n CACHE INTERNAL "")
97+
endif()
98+
99+
# Required for app to compile against nRF Connect SDK <= v1.2
100+
# Must be included after updating Kconfig settings in CMake Cache above
101+
if(DEFINED ENV{MEMFAULT_INCLUDE_ZEPHYR_BOILERPLATE})
102+
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
103+
include($ENV{ZEPHYR_BASE}/../nrf/cmake/boilerplate.cmake)
82104
endif()
83105

84106
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})

examples/nrf-connect-sdk/nrf9160/memfault_demo_app/prj.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD=y
2727
# Required for logging backends to work as expected
2828
CONFIG_LOG=y
2929
CONFIG_LOG_BACKEND_UART=y
30-
# Disable the shell log backend. Rely on the configured backend instead (RTT,
31-
# UART, etc.)
32-
CONFIG_SHELL_LOG_BACKEND=n
3330

3431
# Enable capture of recent logs as part of a coredump
3532
CONFIG_MEMFAULT_LOGGING_ENABLE=y

examples/nrf-connect-sdk/nrf9160/memfault_demo_app/src/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,12 @@ static char s_device_serial[IMEI_LEN + 1 /* '\0' */] = "unknown";
9595

9696
static char s_fw_version[16] = "1.0.0-dev";
9797

98+
#ifndef MEMFAULT_NCS_PROJECT_KEY
99+
#define MEMFAULT_NCS_PROJECT_KEY "<YOUR PROJECT KEY HERE>"
100+
#endif
101+
98102
sMfltHttpClientConfig g_mflt_http_client_config = {
99-
.api_key = "<YOUR PROJECT KEY HERE>",
103+
.api_key = MEMFAULT_NCS_PROJECT_KEY,
100104
};
101105

102106
void memfault_platform_get_device_info(sMemfaultDeviceInfo *info) {

0 commit comments

Comments
 (0)