Skip to content

Commit 806df3e

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 0.32.0 (Build 490129)
1 parent 130caec commit 806df3e

34 files changed

+615
-433
lines changed

CHANGES.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,86 @@
1+
### Changes between Memfault SDK 0.32.0 and SDK 0.31.5 - Aug 7, 2022
2+
3+
#### :chart_with_upwards_trend: Improvements
4+
5+
- [ModusToolbox:tm: Software](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software/)
6+
port updates
7+
- Added heartbeat metrics for heap and Wi-Fi performance tracking when using
8+
the default port for
9+
[CAT1A (PSoC:tm: 6)](https://github.com/Infineon/mtb-pdl-cat1). See
10+
[ports/cypress/psoc6/memfault_platform_core.c](ports/cypress/psoc6/memfault_platform_core.c)
11+
for more details
12+
- Fixed reboot reason reported when PSoC 6 is fully reset to report "Power On
13+
Reset" instead of "Unknown"
14+
- Zephyr port updates
15+
- Memfault logs (eg `MEMFAULT_LOG_DEBUG()` etc) are now routed to the Zephyr
16+
logging infrastructure. The typical set of Kconfig options for Memfault logs
17+
are available (`CONFIG_MEMFAULT_LOG_LEVEL_WRN` etc). See details in
18+
"Breaking Changes" below for enabling logs in your project.
19+
- Added a new Kconfig option, `MEMFAULT_ZEPHYR_FATAL_HANDLER`, which can be
20+
used to disable the Zephyr fault handler print facilities.
21+
22+
#### :boom: Breaking Changes
23+
24+
- Users will no longer see internal Memfault log output by default, but will
25+
have to enable it explicitly to see the output:
26+
27+
```ini
28+
# enable LOG
29+
CONFIG_LOG=y
30+
# not required- enabling the Memfault logging component enables including the
31+
# log buffer in coredumps
32+
CONFIG_MEMFAULT_LOGGING_ENABLE=y
33+
34+
# if on pre-v3.1.0 zephyr, you can choose either the default LOG v1
35+
# implementation, or select a LOG2 mode to enable LOG2. on zephyr 3.1.0+, LOG
36+
# v1 is removed and LOG v2 is now the only log implementation
37+
# CONFIG_LOG2_MODE_DEFERRED=y
38+
39+
# make sure to select a log backend to see the output
40+
CONFIG_LOG_BACKEND_UART=y
41+
```
42+
43+
The log statements affected by this change are likely only the internal
44+
Memfault SDK logs (`MEMFAULT_LOG_DEBUG()` etc), unless those macros are used
45+
in the user application.
46+
47+
- Removed support for Zephyr LTS release 1.14 as it was superseded by
48+
[LTS V2 almost a year ago now](https://www.zephyrproject.org/zephyr-lts-v2-release/).
49+
A project using this release of Zephyr must target a memfault-firmware-sdk
50+
release less than 0.32.0.
51+
52+
#### :house: Internal
53+
54+
- More logically grouped Kconfig settings in Zephyr example app's
55+
[prj.conf](examples/zephyr/apps/memfault_demo_app/prj.conf)
56+
- Fixed a few typos in particle port documentation
57+
- Simplified compilation steps for the
58+
[nRF91 sample test app](examples/nrf-connect-sdk/nrf9160/memfault_demo_app)
59+
when compiling with older releases of the nRF Connect SDK and refreshed the
60+
example to target the v2.0.2 release by default
61+
- Updated default demo CLI commands to better align with
62+
[our suggested integration test commands](https://mflt.io/mcu-test-commands).
63+
The default set now looks like this:
64+
65+
```bash
66+
mflt> help
67+
clear_core: Clear an existing coredump
68+
drain_chunks: Flushes queued Memfault data. To upload data see https://mflt.io/posting-chunks-with-gdb
69+
export: Export base64-encoded chunks. To upload data see https://mflt.io/chunk-data-export
70+
get_core: Get coredump info
71+
get_device_info: Get device info
72+
test_assert: Trigger memfault assert
73+
test_busfault: Trigger a busfault
74+
test_hardfault: Trigger a hardfault
75+
test_memmanage: Trigger a memory management fault
76+
test_usagefault: Trigger a usage fault
77+
test_log: Writes test logs to log buffer
78+
test_log_capture: Trigger capture of current log buffer contents
79+
test_reboot: Force system reset and track it with a trace event
80+
test_trace: Capture an example trace event
81+
help: Lists all commands
82+
```
83+
184
### Changes between Memfault SDK 0.31.5 and SDK 0.31.4 - July 22, 2022
285

386
#### :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: 481181
2-
GIT COMMIT: 95031d142
1+
BUILD ID: 490129
2+
GIT COMMIT: d8f64c57b

components/core/src/arch_arm_cortex_m.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ bool memfault_arch_is_inside_isr(void) {
1919
return ((*ICSR & 0xff) != 0x0);
2020
}
2121

22+
void memfault_arch_disable_configurable_faults(void) {
23+
// Clear MEMFAULTENA, BUSFAULTENA, USGFAULTENA, SECUREFAULTENA
24+
//
25+
// This will force all faults to be routed through the HardFault Handler
26+
volatile uint32_t *SHCSR = (uint32_t*)0xE000ED24;
27+
*SHCSR &= ~((uint32_t)0x000F0000);
28+
}
29+
2230
MEMFAULT_WEAK
2331
void memfault_platform_halt_if_debugging(void) {
2432
volatile uint32_t *dhcsr = (volatile uint32_t *)0xE000EDF0;

components/demo/src/memfault_demo_cli_log.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,24 @@
1111

1212
#include "memfault/core/compiler.h"
1313
#include "memfault/core/log.h"
14+
#include "memfault/config.h"
15+
#include "memfault/core/debug_log.h"
1416

1517
int memfault_demo_cli_cmd_test_log(MEMFAULT_UNUSED int argc,
1618
MEMFAULT_UNUSED char *argv[]) {
19+
MEMFAULT_LOG_DEBUG("Debug log!");
20+
MEMFAULT_LOG_INFO("Info log!");
21+
MEMFAULT_LOG_WARN("Warning log!");
22+
MEMFAULT_LOG_ERROR("Error log!");
23+
24+
#if MEMFAULT_SDK_LOG_SAVE_DISABLE
25+
// MEMFAULT_LOGs are not written to the ram backed log buffer so do
26+
// it explicitly
1727
MEMFAULT_LOG_SAVE(kMemfaultPlatformLogLevel_Debug, "Debug log!");
1828
MEMFAULT_LOG_SAVE(kMemfaultPlatformLogLevel_Info, "Info log!");
1929
MEMFAULT_LOG_SAVE(kMemfaultPlatformLogLevel_Warning, "Warning log!");
2030
MEMFAULT_LOG_SAVE(kMemfaultPlatformLogLevel_Error, "Error log!");
31+
#endif
2132
return 0;
2233
}
2334

components/demo/src/memfault_demo_shell_commands.c

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
#include <stddef.h>
1212

13+
#include "memfault/core/compiler.h"
14+
#include "memfault/core/data_export.h"
1315
#include "memfault/core/debug_log.h"
1416
#include "memfault/core/math.h"
1517
#include "memfault/demo/cli.h"
16-
#include "memfault/core/compiler.h"
17-
#include "memfault/core/data_export.h"
1818

1919
static int prv_panics_component_required(void) {
2020
MEMFAULT_LOG_RAW("Disabled. panics component integration required");
@@ -43,15 +43,30 @@ int memfault_demo_cli_cmd_export(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char
4343
}
4444

4545
static const sMemfaultShellCommand s_memfault_shell_commands[] = {
46-
{"get_core", memfault_demo_cli_cmd_get_core, "Get coredump info"},
4746
{"clear_core", memfault_demo_cli_cmd_clear_core, "Clear an existing coredump"},
48-
{"crash", memfault_demo_cli_cmd_crash, "Trigger a crash"},
49-
{"trigger_logs", memfault_demo_cli_cmd_trigger_logs, "Trigger capture of current log buffer contents"},
5047
{"drain_chunks", memfault_demo_drain_chunk_data, "Flushes queued Memfault data. To upload data see https://mflt.io/posting-chunks-with-gdb"},
51-
{"trace", memfault_demo_cli_cmd_trace_event_capture, "Capture an example trace event"},
52-
{"get_device_info", memfault_demo_cli_cmd_get_device_info, "Get device info"},
53-
{"reboot", memfault_demo_cli_cmd_system_reboot, "Reboot system and tracks it with a trace event"},
5448
{"export", memfault_demo_cli_cmd_export, "Export base64-encoded chunks. To upload data see https://mflt.io/chunk-data-export"},
49+
{"get_core", memfault_demo_cli_cmd_get_core, "Get coredump info"},
50+
{"get_device_info", memfault_demo_cli_cmd_get_device_info, "Get device info"},
51+
52+
//
53+
// Test commands for validating SDK functionality: https://mflt.io/mcu-test-commands
54+
//
55+
56+
{"test_assert", memfault_demo_cli_cmd_assert, "Trigger memfault assert"},
57+
58+
#if MEMFAULT_COMPILER_ARM
59+
{"test_busfault", memfault_demo_cli_cmd_busfault, "Trigger a busfault"},
60+
{"test_hardfault", memfault_demo_cli_cmd_hardfault, "Trigger a hardfault"},
61+
{"test_memmanage", memfault_demo_cli_cmd_memmanage, "Trigger a memory management fault"},
62+
{"test_usagefault", memfault_demo_cli_cmd_usagefault, "Trigger a usage fault"},
63+
#endif
64+
65+
{"test_log", memfault_demo_cli_cmd_test_log, "Writes test logs to log buffer"},
66+
{"test_log_capture", memfault_demo_cli_cmd_trigger_logs, "Trigger capture of current log buffer contents"},
67+
{"test_reboot", memfault_demo_cli_cmd_system_reboot, "Force system reset and track it with a trace event"},
68+
{"test_trace", memfault_demo_cli_cmd_trace_event_capture, "Capture an example trace event"},
69+
5570
{"help", memfault_shell_help_handler, "Lists all commands"},
5671
};
5772

components/demo/src/panics/memfault_demo_panics.c

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
//! @brief
77
//! CLI commands which require integration of the "panic" component.
88

9-
#include "memfault/demo/cli.h"
10-
119
#include <stdlib.h>
1210

11+
#include "memfault/core/arch.h"
1312
#include "memfault/core/compiler.h"
1413
#include "memfault/core/debug_log.h"
1514
#include "memfault/core/errors.h"
1615
#include "memfault/core/platform/core.h"
1716
#include "memfault/core/platform/device_info.h"
1817
#include "memfault/core/reboot_tracking.h"
18+
#include "memfault/demo/cli.h"
1919
#include "memfault/panics/assert.h"
2020
#include "memfault/panics/coredump.h"
2121
#include "memfault/panics/platform/coredump.h"
@@ -110,3 +110,53 @@ int memfault_demo_cli_cmd_clear_core(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED c
110110
memfault_platform_coredump_storage_clear();
111111
return 0;
112112
}
113+
114+
int memfault_demo_cli_cmd_assert(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char *argv[]) {
115+
MEMFAULT_ASSERT(0);
116+
}
117+
118+
#if MEMFAULT_COMPILER_ARM
119+
120+
int memfault_demo_cli_cmd_hardfault(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char *argv[]) {
121+
memfault_arch_disable_configurable_faults();
122+
123+
uint64_t *buf = g_memfault_unaligned_buffer;
124+
*buf = 0xdeadbeef0000;
125+
126+
return -1;
127+
}
128+
129+
int memfault_demo_cli_cmd_memmanage(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char *argv[]) {
130+
// Per "Relation of the MPU to the system memory map" in ARMv7-M reference manual:
131+
//
132+
// "The MPU is restricted in how it can change the default memory map attributes associated with
133+
// System space, that is, for addresses 0xE0000000 and higher. System space is always marked as
134+
// XN, Execute Never."
135+
//
136+
// So we can trip a MemManage exception by simply attempting to execute any addresss >= 0xE000.0000
137+
void (*bad_func)(void) = (void (*)(void))0xEEEEDEAD;
138+
bad_func();
139+
140+
// We should never get here -- platforms MemManage or HardFault handler should be tripped
141+
return -1;
142+
}
143+
144+
int memfault_demo_cli_cmd_busfault(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char *argv[]) {
145+
void (*unaligned_func)(void) = (void (*)(void))0x50000001;
146+
unaligned_func();
147+
148+
// We should never get here -- platforms BusFault or HardFault handler should be tripped
149+
// with a precise error due to unaligned execution
150+
return -1;
151+
}
152+
153+
int memfault_demo_cli_cmd_usagefault(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char *argv[]) {
154+
uint64_t *buf = g_memfault_unaligned_buffer;
155+
*buf = 0xbadcafe0000;
156+
157+
// We should never get here -- platforms UsageFault or HardFault handler should be tripped due to
158+
// unaligned access
159+
return -1;
160+
}
161+
162+
#endif /* MEMFAULT_COMPILER_ARM */

components/include/memfault/core/arch.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ extern "C" {
1717
//! Return true if the code is currently running in an interrupt context, false otherwise
1818
bool memfault_arch_is_inside_isr(void);
1919

20+
//! Disable any configurable fault handlers supported by the platform
21+
void memfault_arch_disable_configurable_faults(void);
22+
2023
#ifdef __cplusplus
2124
}
2225
#endif

components/include/memfault/demo/cli.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,34 @@
1616
extern "C" {
1717
#endif
1818

19+
#include "memfault/core/compiler.h"
20+
1921
//! Command to crash the device, for example, to trigger a coredump to be captured.
2022
//! It takes one number argument, which is the crash type:
2123
//! - 0: crash by MEMFAULT_ASSERT(0)
2224
//! - 1: crash by jumping to 0xbadcafe
2325
//! - 2: crash by unaligned memory store
2426
int memfault_demo_cli_cmd_crash(int argc, char *argv[]);
2527

28+
#if MEMFAULT_COMPILER_ARM
29+
30+
//! Command which will generate a HardFault
31+
int memfault_demo_cli_cmd_hardfault(int argc, char *argv[]);
32+
33+
//! Command which will generate a BusFault on Cortex-M hardware
34+
int memfault_demo_cli_cmd_busfault(int argc, char *argv[]);
35+
36+
//! Command which will generate a Memory Management fault on Cortex-M hardware
37+
int memfault_demo_cli_cmd_memmanage(int argc, char *argv[]);
38+
39+
//! Command which will generate a UsageFault on Cortex-M hardware
40+
int memfault_demo_cli_cmd_usagefault(int argc, char *argv[]);
41+
42+
#endif /* MEMFAULT_COMPILER_ARM */
43+
44+
//! Command which will generate an assert
45+
int memfault_demo_cli_cmd_assert(int argc, char *argv[]);
46+
2647
//! Command to exercise the MEMFAULT_TRACE_EVENT API, capturing a
2748
//! Trace Event with the error reason set to "MemfaultDemoCli_Error".
2849
int memfault_demo_cli_cmd_trace_event_capture(int argc, char *argv[]);

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 = 31, .patch = 5 }
22+
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 32, .patch = 0 }
2323

2424
#ifdef __cplusplus
2525
}

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ find_package(Ncs HINTS $ENV{ZEPHYR_BASE}/../nrf)
2828
# so we set the ones we need here using that:
2929
# https://docs.zephyrproject.org/latest/guides/build/kconfig/setting.html#the-initial-configuration
3030
if (NCS_VERSION_MAJOR)
31-
if (${NCS_VERSION_MAJOR} LESS_EQUAL 1 AND ${NCS_VERSION_MINOR} LESS 6 )
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+
36+
elseif (${NCS_VERSION_MAJOR} LESS_EQUAL 1 AND ${NCS_VERSION_MINOR} LESS 6 )
3237
# Required for logging to work from crash, deprecated in Zephyr included in NCS 1.6
3338
set(CONFIG_LOG_IMMEDIATE y CACHE INTERNAL "")
3439
elseif (${NCS_VERSION_MAJOR} LESS_EQUAL 1 AND ${NCS_VERSION_MINOR} GREATER_EQUAL 6 )
@@ -53,9 +58,13 @@ if (NCS_VERSION_MAJOR)
5358

5459
# For nRF Connect SDK v1.5 default value changed here
5560
set(CONFIG_AT_CMD_SYS_INIT n CACHE INTERNAL "")
56-
else()
57-
# in v1.9+, use the modem_info library to get the IMEI for device_serial
61+
else() # nRF Connect SDK Version >= 1.8.0
62+
# in v1.8+, use the modem_info library to get the IMEI for device_serial
63+
set(CONFIG_MEMFAULT_NCS_DEVICE_ID_RUNTIME y CACHE INTERNAL "")
5864
set(CONFIG_MODEM_INFO y CACHE INTERNAL "")
65+
66+
# Use SPM instead of TFM for Secure Firmware as TFM does not (yet) support forwarding of fault handlers
67+
set(CONFIG_BUILD_WITH_TFM n CACHE INTERNAL "")
5968
endif()
6069
endif()
6170

0 commit comments

Comments
 (0)